如何居中jqGrid弹出模态窗口? [英] how to center jqGrid popup modal window?
问题描述
可能重复:
jqGrid重新放置删除确认框
Possible Duplicate:
jqGrid Reposition Delete Confirmation Box
我已经开始使用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?
感谢您阅读
推荐答案
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";
}
});
您可以在此处现场观看示例.
You can see live the example here.
这篇关于如何居中jqGrid弹出模态窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!