I'm getting data for the kendo-grid DataSource by calling web-API. The sorting and filtering works. Then after I choose a date range from the DatePicker / Range selection I send the range as an object to the server where I cut off the date range needed from an original JSON file and return a new cropped json object back to DataSource. The grid is filled by the data correctly but the sorting/filtering stops working. What can be the problem and solution!? Thanks!
The grid:
var result = $("#grid")
.kendoGrid({
dataSource: {
transport: {
read: {
url: "/api/GridData/GetCustomers",
dataType: "json"
}
},
pageSize: 20
},
height: 550,
filterable: true,
groupable: true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
detailTemplate: kendo.template($("#template").html()),
detailInit: detailInit
},
{
columns: [
{ field: "UniqueClientCode", title: "Уникальный код клиента" },
{ field: "ClientName", title: "Имя клиента" },
{ field: "ClientOKPO", title: "ОКПО клиента" },
{ field: "RegistrationDate", title: "Дата регистрации" },
{ field: "RemovalFromClientsDate", title: "Дата удаления из клиентов" }
]
})
.data("kendoGrid");
How I refresh the grid
function refreshDatePicker () {
// Create new object with date to pass it to API controller and refresh grid
var dateForDatePicker = new Object;
dateForDatePicker.startDate = start._oldText;
dateForDatePicker.endDate = end._oldText;
$.ajax({
type: "POST",
data: dateForDatePicker,
url: "/api/GridData/postDate",
dataType: "json",
success: function (result) {
$("#grid").data("kendoGrid").dataSource = new kendo.data.DataSource({ data: result });
$("#grid").data("kendoGrid").dataSource.read();
$("#grid").data("kendoGrid").refresh();
}
});
}
$("button").on( "click", function() {
refreshDatePicker();
alert("submit clicked");
}
);
});