KendoUI Grid serverpaging

I am trying to fill the KendoUI grid with JSON data, where the server returns the total number of rows along with the data, but I am having problems with serverPage working correctly. I create and assign a grid data source as follows:

                var oDS = new kendo.data.DataSource({
                    schema: {
                        data:  "data",
                        total: "total"
                    },
                    data: self.grdTableData,
                    serverPaging: true,
                    pageSise: 50,
                    total: joOutput["TotalRecords"]
                });

                grdTableResults.setDataSource(oDS);

and the first page shows the first 50 of 939 entries, but there is only 1 page (navigation arrows never react to anything), and I see NaN - NaN of 939 elements and a rotating circle of dots in the center of the grid that never disappears.

, , , , $.ajax JSON .done "transport: read", , , ( , - ?). , , , , , , http://jsfiddle.net/rusev/Lnkug/. "" "", , "startIndex" "rowsPerPage", , . , , . "startIndex" , " ", reset "rowsPerPage"?

, . . !

+5
2

:

": ", , . JS Fiddle.

dataSource: {
    serverPaging: true,
    schema: {
        data: "data",
        total: "total"
    },
    pageSize: 10,
    transport: {
        read: function(options) {
            var data = getData(options.data.page);
            options.success(data);
        }
    },
    update: function() {}
}

, : page, pageSize, skip, take. , , .

startIndex rowsPerPage

, . ajax,

var ajaxPostData = { startIndex: options.data.skip, rowsPerPage: options.data.pageSize }
+7

, :

@(Html.Kendo().Grid<IJRayka.Core.Utility.ViewModels.ProductDto>()
.Name("productList")
.Columns(columns =>
{
    columns.Bound(prod => prod.Name);
    columns.Bound(ord => ord.Brand);
    columns.Bound(ord => ord.UnitPackageOption);
    columns.Bound(ord => ord.CategoryName);
    columns.Bound(ord => ord.Description);
})
.Pageable(pager => pager.PageSizes(true))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.PrefixUrlParameters(false)
.DataSource(ds => ds.Ajax()
            .Model(m => m.Id(ord => ord.ID))
            .PageSize(5)
            .Read(read => read
                .Action("FilterProductsJson", "ProductManagement")
                .Data("getFilters"))
            )
)

getFilters - javascript, , url/service:

function getFilters() {
    return {
        brand: $("#Brand").val(),
        name: $("#Name").val(),
        category: $("#CategoryName").val()
    };
}

, , kendo DataSourceRequest, , , :

public JsonResult FilterProductsJson([DataSourceRequest()] DataSourceRequest request,
                                // three additional paramerters for my custom filtering
                                string brand, string name, string category)
{
    int top = request.PageSize;
    int skip = (request.Page - 1) * top;
    if(brand != null)
        brand = brand.Trim();
    if(name != null)
        name = name.Trim();
    if(category != null)
        category = category.Trim();

    var searchResult = new ManageProductBiz().GetPagedFilteredProducts(brand, name, category, top, skip);
    // remove cyclic references:
    searchResult.Items.ForEach(prd => prd.Category.Products = null);

    return Json(new DataSourceResult { Data = searchResult.Items, Total = searchResult.TotalCount }, JsonRequestBehavior.AllowGet);
}
+3

All Articles