AlertMod警告消息的JQGrid位置 [英] JQGrid position of the AlertMod warning message

查看:129
本文介绍了AlertMod警告消息的JQGrid位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面中有许多jqgrids.弹出警报模式窗口(警告,请选择一行")始终显示在顶部.我希望模式窗口出现在从其生成编辑事件的JQGrid旁边. 使它起作用的唯一方法是将JQGrid源代码更改为以下代码.

I have a number of jqgrids in my page. The popup alert modal window ("Warning Please select a row") is always displayed at the top. I wanted the modal window to appear alongside the JQGrid from which the edit event is generated. The only way I could get this to work was to change the JQGrid source code to the following.

//Line number 7866
if (o.edit) {
    tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
    pEdit = pEdit || {};
    $(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.editicon+"'></span>"+o.edittext+"</div>");
    $("tr",navtbl).append(tbd);
    $(tbd,navtbl)
    .attr({"title":o.edittitle || "",id: pEdit.id || "edit_"+elemids})
    .click(function(){
        if (!$(this).hasClass('ui-state-disabled')) {
            var sr = $t.p.selrow;
            if (sr) {
                if($.isFunction( o.editfunc ) ) {
                    o.editfunc(sr);
                } else {
                    $($t).jqGrid("editGridRow",sr,pEdit);
                }
            } else {
                $.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$t.p.id,jqm:true});

                //***********
                //Added this to change the location of the Warning Alert window
                //Line number 7883
                $("#alertmod")[0].style.top =$("#gbox_"+$t.p.id)[0].offsetTop; 
                //***********

                $("#jqg_alrt").focus();
            }
        }
        return false;

有没有更简单的方法可以实现这一目标,而无需修改src代码.

Is there an easier way to achieve this without modifying the src code.

推荐答案

查看此答案 jqGrid警告,请选择行位置

它可以替代您想要的东西.

it can be one alternative for what you want.

var orgViewModal = $.jgrid.viewModal;
$.extend($.jgrid,{
    viewModal: function (selector,o){ 
        if(selector == '#alertmod'){
            var of = jQuery(o.gbox).offset();       
            var w = jQuery(o.gbox).width();       
            var h = jQuery(o.gbox).height(); 
            var w1 = $(selector).width();
            var h1 = $(selector).height();
            $(selector).css({
                'top':of.top+((h-h1)/2),
                'left':of.left+((w-w1)/2)
            });
        }
        orgViewModal.call(this, selector, o);
    }
}); 

这篇关于AlertMod警告消息的JQGrid位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆