简体   繁体   English

如何选择Kendo Dropdown应该填充Kendo网格

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

I tried this but from my controller data is returning but not binding to kendo grid This is my controller 我尝试了此操作,但是从控制器数据返回但未绑定到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();
            }

        }   
    }

in my .cshtml kendo grid i used this to read 在我的.cshtml剑道网格中,我用它来阅读

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

This is my event in dropdownlist 这是我在下拉列表中的活动

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

There are my functions 有我的功能

 var ddlItem;

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


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

I Finally got with this, 我终于明白了

  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