Frage

I tried this but from my controller data is returning but not binding to kendo grid This is my controller

 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

  .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();
}
War es hilfreich?

Lösung

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();
            }
    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top