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

时间:2014-02-04 08:59:13

标签: asp.net-mvc-4 kendo-grid kendo-dropdown

我尝试了这个但是从我的控制器数据返回但没有绑定到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();
}

1 个答案:

答案 0 :(得分:0)

我终于得到了这个,

  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();
            }
    }