【问题标题】:How to get Kendo Dropdown selected should fill Kendo grid如何选择剑道下拉菜单应该填充剑道网格
【发布时间】:2014-02-04 08:59:13
【问题描述】:

我试过了,但我的控制器数据正在返回但没有绑定到剑道网格 这是我的控制器

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

【问题讨论】:

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


【解决方案1】:

我终于明白了,

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多