jqGrid 阻止寻呼机导航?
我们使用自定义格式化程序来输出 html 表单文本框。如果用户输入了数据并点击了下一个/上一个按钮,我们想告诉他们“您已经编辑了数据,点击确定以留在此页面并保存您的数据”。你怎么能这样做呢?
当您使用寻呼机时,会触发 'onPaging' 事件,但它似乎不允许您阻止分页的发生。
更新:当前解决方法:
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';
},
更新 2:记录错误此处。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果函数 onPaging 返回“stop”,则分页将被停止。
If the function onPaging returns 'stop' then the pagination will be stopped.
根据我的观察,onPaging 事件在最新的 jqgrid 插件中运行良好。虽然如果我们使用以前的 jqgrid 插件(3.8 版本之前)。onPaging 事件将起作用,但是,在我们使用此事件后分页中存在错误。因为它会自动增加页面的值用户单击“确定”或“取消”(在这两种情况下)。这会导致分页数据损坏。
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.