I am attempting to set the DataSource of a Kendo grid through javascript but i am getting an error:
Unhandled exception at line 11, column 19155 in http://localhost:55135/Scripts/kendo/kendo.all.min.js
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'slice'
i have created my create as below:
On the click of a search button i execute some javascript to populate the grid:
It calls an Action on the controller:
Any help appreciated.
Unhandled exception at line 11, column 19155 in http://localhost:55135/Scripts/kendo/kendo.all.min.js
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'slice'
i have created my create as below:
<div id="grid"> @(Html.Kendo().Grid(Model.ClientLoans) .Name("grdResults") .Columns(columns => { columns.Bound(loan => loan.ClientName); columns.Template(@<text>@Html.ActionLink(@item.AssetNumber, "ViewDetail", new { clientLoan = @item, id = @item.AssetNumber })</text>).Title("Asset Number"); }) .Pageable() .Sortable() .DataSource(dataSource => dataSource .Ajax() .PageSize(5) .Read(read => read.Action("SearchTest","ClientLoanSearch")) ) ) </div>On the click of a search button i execute some javascript to populate the grid:
$("#btnSearch").click(function () { var searchParameters = GetSearchParameters(); var jsonData = JSON.stringify(searchParameters, null, 2); $.ajax({ url: '@Url.Content("~/ClientLoanSearch/SearchTest")', type: 'POST', data: jsonData, datatype: 'json', contentType: 'application/json; charset=utf-8', success: function (data) { //debugger; var results = data; var dataSource = new kendo.data.DataSource({ data: results //dataType: "json", //columns: [ // { field: "ClientHcn", title: "Client HCN" }, // { field: "AssetNumber", title: "Asset Number" }] }); var grid = $('#grdResults').data('kendoGrid'); grid.setDataSource(dataSource); //grid.dataSource.read(); }, error: function (request, status, err) { alert(status); alert(err); } }); return false; });It calls an Action on the controller:
[HttpPost] public ActionResult SearchTest([DataSourceRequest]DataSourceRequest request, ClientLoanSearchModel model) { Library.ClientLoanCollection loans = Library.ClientLoanCollection.GetDummyData(); var jsonData = new {loans}; DataSourceResult result = loans.ToDataSourceResult(request); return Json(result, JsonRequestBehavior.AllowGet); }Any help appreciated.