Search code examples
jqueryflexigrid

Flexigrid not paging


I have a jQuery flexigrid that is displaying items 1-10 of 15 on the first page but the paging does not work. I.e. when I request the second page, the data remains the same. Any ideas?

Here's the config:

$("#tblLists").flexigrid({
    url: '/lists/load/',
    dataType: 'json',
    colModel : [
        {display: 'Name', name : 'name', width : 900, sortable : true, align: 'left'},
        {display: 'Recipients', name : 'recipients', width : 200, sortable : true, align: 'left'}
        ],
    searchitems : [
        {display: 'Name', name : 'name', isdefault: true}
        ],
    sortname: "name",
    sortorder: "desc",
    usepager: true,
    title: 'Lists',
    useRp: true,
    rp: 10,
    width: 'auto',
    height: 200,
    singleSelect: true,
    onSuccess: function(){
        $('.flexigrid tr').dblclick(function(event){
            console.log($(this).attr('id').substr(3));
        });
    }, 
});

Solution

  • I'm guessing that your /lists/load/ url returns all 12 items at once. FlexiGrid doesn't support client side pagination ( it sucks..but they don't ). They expect you to implement pagination on the server side. So if rp is 10 and page = 1 you return results 1 to 10. If rp is 10 and page = 2 you return results 11 to 20. Same goes for sorting. Flexigrid will pass you the sort parameter and you need to sort on the server side and return sorted data.