Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid prevent pager navigation?

We use a custom formatter to output html form text boxes. In the case that a user has entered in data and they hit the next/prev button, we want to tell them "you've edited data, hit ok to stay on this page and save your data". How can you do this?

The 'onPaging' event fires when you use the pager but it doesn't seem to let you prevent the pagination from occuring.


Update: Current workaround:

var currPg = 1;
var dirty = 'false';


  $("#list").jqGrid({
    ...
    onPaging: function (b) {
        var nextPg = $("#list").getGridParam("page");

        if (dirty == 'false') {
           currPg = nextPg;
           return;
        }


        $( "#dialog-confirm" ).dialog({
        modal: true,
        buttons: {
            "Stay on current page": function() {
                $( this ).dialog( "close" );
            },
            "Change page": function() {
                $( this ).dialog( "close" );
                reloadGrid($("#list"), null, nextPg, 'false');
            }
        }
        });

        $("#list").setGridParam({page:currPg}); //Workaround - jqGrid still increments the page num even when we return stop so we have to reset it (and track the current page num)    
        return 'stop';
    },

Update 2: Bug logged here.

like image 511
Marcus Leon Avatar asked Sep 27 '10 16:09

Marcus Leon


1 Answers

If the function onPaging returns 'stop' then the pagination will be stopped.

like image 147
Oleg Avatar answered Sep 29 '22 12:09

Oleg