Question

Spend quite a lot of time trying to find how to set default refresh button on pager of jqGrid to refresh current page, but with no luck.

here is my grid in short:

$grid = $("#schedule");
var last_selected_row;
$grid.jqGrid({
    url:'xtras/schedule.php',
    editurl:'xtras/schedule.php',
    datatype: "json",
    mtype:'GET',
    colModel:[
        .................................   
    ],
    height: "100%",
    minWidth: 900,
    rowNum:15,
    rowList:[10,15,20,30,50,100],
    viewrecords: true,
    sortname:"ID",
    sortorder: "desc",
    pager: '#schedule_pager',
    caption:"Snapper Release Schedule",

    loadonce:false,
    ajaxGridOptions: {cache: false},

    grouping:true,
    groupingView : {
        groupField : ['Date'],
        groupColumnShow : [true],
        groupOrder: ['desc'],
        groupDataSorted : true
    },

    gridview: true,

    ondblClickRow: function (row_id) {
        if(row_id != null) {
            if(row_id !== last_selected_row) {
                jQuery('#schedule').jqGrid('restoreRow',last_selected_row);
                jQuery('#schedule').jqGrid('saveRow',row_id);
                jQuery("#schedule").jqGrid('editRow',row_id, true, null, 
                    function(){ $("#schedule").trigger("reloadGrid", [{current: true}]); }, 
                    'xtras/schedule.php', 
                    null,{},{},{}
                );
                last_selected_row = row_id; 
            } else {
                last_selected_row=row_id;
            }
        } 
    }
});

$grid.jqGrid('setGroupHeaders', {
    useColSpanStyle: true, 
    groupHeaders:[
        {startColumnName: 'Date', numberOfColumns: 11, titleText: '<em>Main Info</em>'},
        {startColumnName: 'Sales Text', numberOfColumns: 4, titleText: '<em>Deadlines</em>'}
    ]
});

$grid.jqGrid('navGrid','#schedule_pager',{edit:false,add:false,del:false},{},{},{},{});

Now there is search, refresh and pagination in pager, whenever I'm on any page other than first and hit refresh - it reloads to the first page. How to set it to reload current page? (when I trigger reload grid, I use [{current: true}], but how do I set it to default refresh button?)

Was it helpful?

Solution

You need just use refreshstate: "current" option of navGrid:

$grid.jqGrid("navGrid", "#schedule_pager",
    {edit: false, add: false, del: false, refreshstate: "current"}
);

By the way, if you use navGrid mostly to create the pager with "Search" and "Refresh" buttons you can change defaults of navGrid and use later simplified call of navGrid:

$.extend($.jgrid.nav, {
    edit: false,
    add: false,
    del: false
    refreshstate: 'current'
});
...
$grid.jqGrid("navGrid", "#schedule_pager");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top