Kendo Grid UI - serverPaging issue in asp.net core.

1 Answer 120 Views
Grid
Santosh
Top achievements
Rank 1
Santosh asked on 25 Jan 2022, 11:51 AM

Hi Team,

 

We follow your example : https://docs.telerik.com/kendo-ui/knowledge-base/retrieve-visible-grid-columns-data-with-select-odata-parameter.

We just replace with our API endpoint and columns fields. Its returns only 20 records first page of records. Rest of the records not showing.

API returns json format.

[
    {
        "workflowId": 48,
        "id": 177,
        "workflowName": "Observations",
    },
    {
        "workflowId": 64,
        "id": 178,
        "workflowName": "IncidentManagement",
    },
    {
        "workflowId": 64,
        "id": 183,
        "workflowName": "IncidentManagement",
    },
    {
        "workflowId": 64,
        "id": 185,
        "workflowName": "IncidentManagement",
    },
]

-----------------------------------------

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 28 Jan 2022, 06:42 AM

Hello Santosh,

The provided details are not enough to be sure what is causing the issue. Therefore I modified the Telerik ASP.NET Core Grid oData Binding example with the approach suggested and it works on my end. For details on the backend configuration refer to the GitHub service repository and the equivalent ASP.NET Core Grid configuration is:

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.OrderID).Filterable(false);
        columns.Bound(e => e.Freight);
        columns.Bound(e => e.OrderDate).Width(120).Format("{0:MM/dd/yyyy}");
        columns.Bound(e => e.ShipName).Width(260);
        columns.Bound(e => e.ShipCity).Width(150);
    })
    .DataSource(dataSource => dataSource
        .Custom()
        .Type("odata")
        .Transport(transport =>
           transport.Read(read => read.Url("https://demos.telerik.com/kendo-ui/service/Northwind.svc/Orders").Data("additionalData"))
        ) 
        .PageSize(20)
        .ServerPaging(true)
        .ServerSorting(true)
        .ServerFiltering(true)
    )
    .ColumnMenu()
    .Events(ev=>ev.ColumnShow("onColumnShow"))
    .Pageable()
    .Sortable()
    .Filterable()
)
<script>
    function onColumnShow(e){
        e.sender.dataSource.read();
    }
    function additionalData(){
        return {
            $select:getColumns
        }
    }
    function getColumns() {
            return $("#grid").data("kendoGrid")
                .columns
                .filter(item => !item.hidden)
                .map(function(item) {
                    return item.field
                }).join(",");
        }
</script>

Here is a REPL where you can inspect the above. Hide a page from the column menu and navigate to another page. Inspect the Network Tab and note only data for the visible columns is returned.

I hope this helps.

Regards,
Aleksandar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Santosh
Top achievements
Rank 1
Answers by
Aleksandar
Telerik team
Share this question
or