jQWidgets Forums

jQuery UI Widgets Forums Grid Issue with jqxGrid total record number

This topic contains 2 replies, has 2 voices, and was last updated by  Peter Stoev 11 years, 1 month ago.

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

  • mihaisinger
    Participant

    Hello
    I’m using the jqxGrid in virtual mode with server paging, and updating the source.totalrecords value in the adapter’s downloadComplete event (see the attached code). However, if the total number of records, and thus the source.totalrecords value, is greater than the grid’s current page size, the pager displays the page size as the total number of records, and the grid’s paging does not work. If I then change the page size from the drop down menu to exceed to real total number of records, the total number of records becomes correct… but that defeats the purpose of having a pager.
    For example, my grid has page size options for 100, 200 and 400 records, and the initial page size is 100. My server returns 188 records, and so I set source.totalrecords to 188. However, my grid’s pager shows “Show rows 1-100 of 100”. If I change the page size to 200, the pager will display “Show rows 1-188 of 188”.
    I verified that the source.totalrecords value is 188 in both cases.
    Here’s my code:

    source = {
    datatype: “xml”,
    datafields: [
    { name: ‘ReferralId’ },
    { name: ‘FormattedName’ },
    { name: ‘ServiceName’ },
    { name: ‘InitialDate’ },
    { name: ‘CurrentStatus’ },
    { name: ‘CurrentStatusDate’ }
    ],
    type: ‘POST’,
    totalrecords: 1000,
    formatdata: function (data) {
    return JSON.stringify({ name: $(“#txtSearchName”).val(), pagenum: data.pagenum, pagesize: data.pagesize })
    },
    record: ‘Table’,
    url: ‘ReferralSearch.aspx/GetReferrals’
    };

    var dataAdapter = new $.jqx.dataAdapter(source,
    { contentType: ‘application/json; charset=utf-8’,
    loadError: function (jqXHR, status, error) {
    alert(error);
    },
    downloadComplete: function () {
    $.ajax({
    url: ‘ReferralSearch.aspx/GetTotalRowsCount’,
    contentType: ‘application/json; charset=utf-8’,
    data: JSON.stringify({
    name: $(“#txtSearchName”).val()
    }),
    async: false,
    type: ‘POST’,
    success: function (data) {
    source.totalrecords = data.d;
    //alert(source.totalrecords);
    }
    });
    }
    }
    );

    $(“#dvGrid”).jqxGrid({
    source: dataAdapter,
    pageable: true,
    pagesizeoptions: [‘100’, ‘200’, ‘300’, ‘400’],
    pagesize: 100,
    virtualmode: true,
    selectionmode: ‘singlerow’,
    width: ‘775px;’,
    height: ‘100%’,
    theme: jqxTheme,
    rendergridrows: function (args) {
    return args.data;
    },
    columns: [
    { text: ‘ReferralId’, dataField: ‘ReferralId’, hidden: true },
    { text: ‘Name’, dataField: ‘FormattedName’, pinned: true, width: 200 },
    { text: ‘Service’, dataField: ‘ServiceName’, width: 155 },
    { text: ‘Initial date’, dataField: ‘InitialDate’, width: 110 },
    { text: ‘Status’, dataField: ‘CurrentStatus’ },
    { text: ‘Status date’, dataField: ‘CurrentStatusDate’, width: 110 },
    ]
    });

    What am I doing wrong? Thank you.

    Regards
    Mihai


    mihaisinger
    Participant

    Can anyone shed any light over this?
    Thank you.

    Mihai


    Peter Stoev
    Keymaster

    Hi Mihai,

    There’s a working demo which shows how the functionality should be implemented: http://www.jqwidgets.com/jquery-widgets-demo/demos/php/serverpaging.htm?arctic. source.totalrecords should point to the records which can be displayed, not to the amount of records in the current page.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.