jQWidgets Forums

jQuery UI Widgets Forums Grid Grid Server Paging totalrecords has no effect

This topic contains 4 replies, has 2 voices, and was last updated by  aleidenfrost 5 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • aleidenfrost
    Participant

    Hi all,

    I used the example at https://www.jqwidgets.com/jquery-widgets-documentation/documentation/asp.net-integration/asp.net-grid-server-side-paging.htm to build a grid with server paging but there is a problem: even though I set the totalrecords in beforeprocessing (and the number is set to 1000, I checked in the debugger), the grid says it shows 10 out of 10 total records and there effectively is no paging. The data it shows is the correct data, just the totalrecords seems to have no effect.

    What am I doing wrong? Everything is set up like in the example:

    $(document).ready(function () {
                var dataSource = {
                    datatype: "json",
                    datafields: [
                        { name: 'ID', type: 'int' },
                        { name: 'Date', type: 'date' },
                        { name: 'Name', type: 'string' }
                    ],
                    url: 'Controller/GetData',
                    root: 'Rows',
                    cache: false,
                    beforeprocessing: function (data) {
                        dataSource.totalRecords = data.TotalRows;
                    }
                };
                var dataAdapter = new $.jqx.dataAdapter(dataSource);
                $("#dispalRingGrid").jqxGrid({
                    source: dataAdapter,
                    pageable: true,
                    virtualmode: true,
                    columnsresize: true,
                    columnsreorder: true,
                    rendergridrows: function () { return dataAdapter.records; },
                    columns: [
                        { datafield: 'ID' },
                        { datafield: 'Date', type: 'date' },
                        { datafield: 'Name', type: 'string' }
                    ]
                });
            });

    Hristo
    Participant

    Hello aleidenfrost,

    When you use the virtualmode it is important to create a correct implementation of its following callback – rendergridrows.
    Please, try to implement the “rendergridrows”:

    virtualmode: true,
                rendergridrows: function (obj) {
                    return obj.data;
                }

    As it is in the mentioned tutorial.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    aleidenfrost
    Participant

    Hi Hristo,

    thanks, but that’s what I tried first, following the tutorial. When that didn’t work I looked around for other examples; I got passing the adapter records in the rendergridrows method there.
    Both options don’t work.

    Is there some additional option I have to set for GridView to recognize totalrecords?


    Hristo
    Participant

    Hello aleidenfrost,

    I would like to ask you – is there any error message in the console?
    Also, could you check the result of the request to the server?
    Another thing that I would like to suggest you is to implement the loadError(jqXHR, status, error) callback into the jqxDataAdapter.
    On that way, we will receive some feedback.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    https://www.jqwidgets.com


    aleidenfrost
    Participant

    Hi Hristo,

    thanks for your advice. The server result was fine and there was no error. So I started going over the tutorial again line by line and I found my error.
    It’s this:

    beforeprocessing: function (data) {
                        dataSource.totalRecords = data.TotalRows;
                    }

    I used camel case for totalrecords instead of all small letters. Once I fixed that, it worked fine.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.