簡體   English   中英

如何選擇Kendo Dropdown應該填充Kendo網格

[英]How to get Kendo Dropdown selected should fill Kendo grid

我嘗試了此操作,但是從控制器數據返回但未綁定到Kendo網格這是我的控制器

 public ActionResult Index(string LocationId)
    {
        using (var client = new HttpClient())
        {
            IList<AssetsByLocation> _assetCompanyDetailslist;

            AssetRepository assetrep = new AssetRepository();
            Guid LocationID = new Guid();
            if (Request.Params["LocationId"] != null)
            {
                LocationID = new Guid(Request.Params["LocationId"].ToString());
                _assetCompanyDetailslist = assetrep.GetAssetsForLocation(LocationID);
                var model = _assetCompanyDetailslist;
                return View(model);
            }
            else
            {
                return View();
            }

        }   
    }

在我的.cshtml劍道網格中,我用它來閱讀

  .Read(read => read.Action("Index", "AssetByLocation").Data("getMsgType"))

這是我在下拉列表中的活動

  .Events(events => events.Change("OnMsgTypeChange"))

有我的功能

 var ddlItem;

function getMsgType() {
    return {
        LocationId: ddlItem
    }
}


function OnMsgTypeChange(e) {
    ddlItem = this.value();
    $("#Grid").data("kendoGrid").dataSource.read();
}

我終於明白了

  public ActionResult Index([DataSourceRequest]DataSourceRequest request, string LocationId)
    {
            if (Request.Params["LocationId"] != null)
            {
                using (var client = new HttpClient())
                {
                    AssetRepository assetrep = new AssetRepository();
                    Guid LocationID = new Guid();
                    LocationID = new Guid(Request.Params["LocationId"].ToString());
                    var msgs = assetrep.GetAssetsForLocation(LocationID).ToDataSourceResult(request);
                    return Json(msgs);
                }
            }
            else
            {
                return View();
            }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM