【问题标题】:JQGrid position of the AlertMod warning messageAlertMod 警告消息的 JQGrid 位置
【发布时间】:2012-02-07 19:59:57
【问题描述】:

我的页面中有许多 jqgrids。弹出警报模式窗口(“警告请选择一行”)始终显示在顶部。我希望模态窗口出现在生成编辑事件的 JQGrid 旁边。 我可以让它工作的唯一方法是将 JQGrid 源代码更改为以下内容。

//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 代码的情况下实现这一点。

【问题讨论】:

    标签: jqgrid


    【解决方案1】:

    看到这个答案jqGrid warning please select row position

    它可以是您想要的另一种选择。

    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);
        }
    }); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-12
      • 2021-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 2019-10-03
      • 2015-08-07
      相关资源
      最近更新 更多