I am having kendo grid which loads initially with these data.
@(Html.Kendo().Grid<GridModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ID).Hidden(true);
columns.Bound(p => p.Name);
columns.Bound(p => p.Village);
columns.Command(command =>
{
command.Custom("ButtonP");
command.Custom("ButtonEdit");
command.Custom("ButtonActive");
command.Custom("ButtonPause");
}).Width("20%").HtmlAttributes(new { @class = "Custom" });
})
.Reorderable(reordering => reordering.Columns(true))
.HtmlAttributes(new { style = "margin-bottom: 20px;" })
.Sortable()
.EnableCustomBinding(true)
.ColumnMenu()
.AutoBind(false)
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetData", "Home"))
// .PageSize(30)
.ServerOperation(true)
)
.Events(e => e.DataBound("ModifyButtons"))
)
After this there is a search button which calls the backend to get the records and total by a ajax call.If I include all records it goes for paging but when I go for server paging It is not fetching count or total records. Working ajax
var dataSource = new kendo.data.DataSource({
data: response
});
$("#Grid").data("kendoGrid").setDataSource(dataSource);
and backend
var searchItems = Service.Search(SearchModel).Select(GridModel);
return Json(searchItems, JsonRequestBehavior.AllowGet);
But I want to do server paging and when I return this (Non Working Ajax)
var dataSource = new kendo.data.DataSource({
data: response.Data,
total: response.Total
});
$("#Grid").data("kendoGrid").setDataSource(dataSource);
and backend
var searchItems = Service.Search(SearchModel).Select(GridModel);
var records = new
{
Data = searchItems,
Total = 90
};
return Json(records, JsonRequestBehavior.AllowGet);
==Hard coded total to test. SearchModel contains parameters for a complex search
Please tell me how to find the total from server side it is just showing current page size as total count.