开发者

jqGrid cell editing need to position the error message dialog

开发者 https://www.devze.com 2023-01-03 08:17 出处:网络
I\'m using jqGrid with cell editing.I have setup the colModel properties using the editrules option.Everything works fine in th开发者_开发技巧at if I edit a cell and try to save an invalid value the g

I'm using jqGrid with cell editing. I have setup the colModel properties using the editrules option. Everything works fine in th开发者_开发技巧at if I edit a cell and try to save an invalid value the grid displays an error dialog, but I need to know how to position the error message dialog that comes up because in the case of my layout it ends up behind a video. I'm not quite sure how to hook into this and there don't seem to be any obvious options on how to do it.

In this case the dialog I would be trying to manipulate is the one with ID of info_dialog.

Also I'm using the clientArray option for cellsubmit.


I realize this is rather old but upon searching I didn't find any indication this might have been added since, so I figured now that I've figured it out I'd let everyone know how I solved the positioning of mine.

$(document).ready(function ()
{
    $.jgrid.jqModal = $.extend($.jgrid.jqModal || {}, {
        beforeOpen: centerInfoDialog
    });
});

function centerInfoDialog()
{
    var $infoDlg = $("#info_dialog");
    var $parentDiv = $infoDlg.parent();
    var dlgWidth = $infoDlg.width();
    var parentWidth = $parentDiv.width();

    $infoDlg[0].style.left = Math.round((parentWidth - dlgWidth) / 2) + "px";
}

From what I could find in the jqGrid source code, you can add a beforeOpen and an afterOpen. In my case I'd rather position the thing before it's displayed (duh!). Would be nice if there was a parameter to hook it up in the grid declaration, but this does the trick in the mean time.

I hope this helps someone! I spent most of my afternoon on this!


Default value of zIndex parameter of info_dialog is 1000. The function info_dialog from grid.common.js part of jqGrid will be called from grid.celledit.js without usage a 4-th parameter which can change the option.

So the best pragmatical way which I could recomend you is to decrease zIndex value of your div with the video so that it will be less then 1000.

0

精彩评论

暂无评论...
验证码 换一张
取 消