There is a kendo grid for which the transport is registered in the datasource

setDataSourceListGrid = function (obj) { var _grid = $("#MainGrid").data("kendoGrid"); var selectedRow = $(obj).closest("tr"); var selectedItem = _grid.dataItem(selectedRow); var Id = selectedItem.Id; // Этот Id отправляем на сервер dataSourceListGrid = new kendo.data.DataSource({ transport: { read: { url: "AwardHonorary/awardListGrid/", dataType: "json", type: "POST", data: { id: Id }, error: function (data) { alert("Ошибка при чтении данных."); }, complete: function (e) { } } }, pageSize: 10, serverSorting: true, serverFiltering: true, serverPaging: true, alowUnsort: true, schema: { data: function (data) { return data.List || []; }, total: "Count", model: { fields: { "field1": { editable: false, type: "int" }, "field2": { editable: false, type: "int" }, "field3": { editable: false, type: "string" }, "field4": { editable: false, type: "string" }, "field5": { editable: false, type: "string" } } } } }); return dataSourceListGrid; } 

Grid is registered as:

 $("#awardContendersGrid").kendoGrid({ pageable: { messages: { display: "{0} - {1} из {2} элементов", empty: "Список пуст", page: "Страница", of: "из {0}", itemsPerPage: "элементов на страницу", refresh: "Обновить" } }, resizable: true, sortable: true, columnMenu: false, dataSource: setDataSourceListGrid (obj), columns: [ { field: "field1", title: "Поле1", type: "int", hidden: true }, { field: "field2", title: "Поле2", type: "int", width: "30px" }, { field: "field3", title: "Поле3", type: "string", width: "200px" }, { field: "field4", title: "Поле4", type: "string", width: "150px" }, { field: "field5", title: "Поле5", type: "string", width: "250px" }, ] }); 

}

On the server, the receiving method looks like this:

 [HttpPost] public JsonResult Test(Int64 id, int take, int skip, int page, int pageSize, List<GridSort> sort = null) { 

In fidler catches the request sent by the adjac and shows the following:

id = 1 & take = 10 & skip = 0 & page = 1 & pageSize = 10 & sort% 5B0% 5D% 5Bfield% 5D = HomeAdress & sort% 5B0% 5D% 5Bdir% 5D = asc

Those. see that no serialization occurs in the json object

At the same time, the Int64 id, int take, int skip, int page, int pageSize variables come to the method on the server itself, but the sorting does not. Knowledgeable people tell me what is missing?

PS ServerSorting setting: true for kendo grid enabled

  • The piece of zhs that you put on is not enough to help solve your problem. - Mstislav Pavlov
  • Mstislav, what else is required? - Dmitry
  • Ideally, sweep your code in a telerikov dojo - Mstislav Pavlov
  • Mstislav, added the description in the question - Dmitry
  • Did you want to add a sort? - Mstislav Pavlov

1 answer 1

You do not have the correct controller method, it should look like this:

 public DataSourceResult Read([DataSourceRequest] DataSourceRequest request) { IQueriable myQ ...; // Тут происходит кендо-магия. В `request` содержатся всякие клиентские параметры, типа сортировок, пейджинг, фильтрация и прочее. return myQ.ToDataSourceResult(request); } 
  • but Id the same parameter in the request will not fall? - Dmitry
  • If you need to pass extra. parameter, then simply add the int id parameter after the request . The parameter must be passed by specifying it in the URL in the form &id=123 - Mstislav Pavlov
  • Mstislav, and you can somehow do without DataSourceResult? I do not have this class in the project, and adding something is not very desirable. In any case, thank you very much for your help!) - Dmitry
  • KendoUI is the standard class for KendoUI like the .ToDataSourceResult method. If you don’t have them in the project, it means that you didn’t connect the KendoUI libraries to the project, which I strongly recommend you to do, since you are working with kendo from C # - Mstislav Pavlov
  • clear. Thanks again Mstislav! - Dmitry