如何居中 jqGrid 弹出模式窗口? [英] how to center jqGrid popup modal window?
问题描述
可能重复:
jqGrid 重新定位删除确认框
我已经开始使用 jqGrid 几天了,一切都很好.到目前为止一切都很好.让我感到惊讶的是,当您单击 NavGrid
中的编辑按钮而不选择行时,它会显示一个居中的模式弹出窗口,通知未选择任何行.但是当您单击添加或编辑(带有选定的行)时,它会在网格的左侧显示一个模式.根本没有居中.
I've started using jqGrid for few days and everything is working cool.so far so good.
What borders me is that when you click on edit button in the NavGrid
without selecting a row, it shows a centered modal popup notifying of no row being selected.
But when you click on add or edit(with selected row) it shows a modal at the left side of the grid.Not centered at all.
我想找到一种方法来居中.
I'll like to find a way to center it.
这是怎么做到的?还是不能开箱即用?
How is that done? or it can not be done out of the box?
感谢阅读本文
推荐答案
在我看来,最简单的方法是改变 beforeShowForm 事件:
It seems to me, that the easiest way to do this is to change the dialog position inside of the beforeShowForm event:
var grid = $("#list");
grid.jqGrid('navGrid','#pager',
{add:false,del:false,search:false,refresh:false},
{ beforeShowForm: function(form) {
// "editmodlist"
var dlgDiv = $("#editmod" + grid[0].id);
var parentDiv = dlgDiv.parent(); // div#gbox_list
var dlgWidth = dlgDiv.width();
var parentWidth = parentDiv.width();
var dlgHeight = dlgDiv.height();
var parentHeight = parentDiv.height();
// TODO: change parentWidth and parentHeight in case of the grid
// is larger as the browser window
dlgDiv[0].style.top = Math.round((parentHeight-dlgHeight)/2) + "px";
dlgDiv[0].style.left = Math.round((parentWidth-dlgWidth)/2) + "px";
}
});
您可以在此处查看示例.
这篇关于如何居中 jqGrid 弹出模式窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!