jqGrid prevent pager navigation?

亡梦爱人 提交于 2019-12-21 17:00:02

问题


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.


回答1:


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




回答2:


As per my observation onPaging event works well in latest jqgrid plugin.While if we use previous jqgrid plugin ( before 3.8 version).onPaging event will work but,there is bug in pagination after we use this event.As it automatically increment value of page either user click on ok or cancel(in both cases).Which lead to corrupt data of paggination.



来源:https://stackoverflow.com/questions/3805832/jqgrid-prevent-pager-navigation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!