jqGrid单元格内的jQuery UI菜单

问题描述:

我已经创建了一个网格并自定义了一个包含jquery UI菜单的列,如拆分按钮"示例

I have created a grid and customized a column to contain a jquery UI menu like in the Split Button example

除了菜单窗口出现在单元格内部会导致不良的视觉效果(也就是说,单元格的高度增加为菜单窗口腾出空间)之外,其他所有方法都工作正常. 请看下面的屏幕截图,以得到直观的解释(不要介意处于禁用状态的菜单项).

Everything works fine except for the fact that the menu window appear inside the cell causing a bad visual effect, that is, the cell height increase to make room for the menu window. Have a look at the following screenshot for a visual explanation (nevermind about the menu item in disabled state).

有什么方法可以使菜单窗口以z-index的形式出现在表格元素的顶部?

Is there any way way to make the menu window appear on top of the table element in term of z-index?

非常感谢您的宝贵帮助,社区:)

Thanks very much for your valuable help, community :)

根据评论请求进行

下面是创建splitbutton菜单的代码.首先,列模型标记

The code to create the splitbutton menu is the following. First the column model markup

{ name: 'act', index: 'act', width: 80, sortable: false, search: false, align: 'center',
  formatter: function (cellvalue, options, rowObject) {
      var markup = "<div>" +
                      "<div class='actionsButtonset'>" +
                          "<button class='dshbd_ConfirmMonth' rel='" + rowObject.UmltID + "' rev='" + rowObject.IsConfirmAvailable + "' plock='" + rowObject.IsPeriodLocked + "' alt='Confirm'>Confirm</button>" +
                          "<button class='btnSelectMenu' rev='" + rowObject.IsUmltLocked + "' " + ">Select</button>" +
                      "</div>" +
                      "<ul class='actionMenu'>" +
                          "<li><a class='dshbd_UnlockMonth' href='#' rel='" + rowObject.UmltID + "' alt='Unlock'>Unlock</a></li>" +
                      "</ul>" +
                   "</div>";
      return markup;
  }
}

然后,在gridComplete事件内部,我有以下代码(请注意,启用/禁用菜单项需要一些代码

Then, inside the gridComplete event I have the following code (please note that some code is needed to enable/disable menu items

var confirmMonthBtn = $('.dshbd_ConfirmMonth');
$.each(confirmMonthBtn, function (key, value) {
    var button = $(this);
    var umltID = button.attr('rel');
    button.button().click(function (event) {
        event.preventDefault();
    });
    var isPeriodLocked = (button.attr('plock') === 'true');
    if (!isPeriodLocked) {
        var isConfirmAvailable = ($(this).attr('rev') === 'true');
        if (!isConfirmAvailable) {
            button.button({ disabled: true });
        }
    } else {
        button.button({ disabled: true });
    }
});
var currentPeriod = GetCurrentPeriod();
var period = GetCurrentViewPeriod();
var isCurrent = false;
if (currentPeriod != null && period != null) {
    isCurrent = period.PeriodID == currentPeriod.PeriodID;
}
var selectBtns = $('.btnSelectMenu');
$.each(selectBtns, function (key, value) {
    var button = $(this);
    button.button({ text: false, icons: { primary: 'ui-icon-triangle-1-s'} });
    button.click(function (event) {
        var menu = $(this).parent().next().show();
        menu.position({
            my: 'left top',
            at: 'left bottom',
            of: this
        });
        $(document).on('click', function () {
            menu.hide();
        });
        return false;
     });
     $('div.actionsButtonset').buttonset();
     var menuElement = button.parent().next();
     menuElement.hide();
     menuElement.menu({
         select: function (event, ui) {
             var umltID = ui.item.children().attr('rel');
             event.preventDefault();
         }
     });
     if (!isCurrent) {
         var isPeriodLocked = ($(this).attr('plock') === 'true');
         if (isPeriodLocked) {
             menuElement.menu({ disabled: false });
         } else {
             var isUmltLocked = ($(this).attr('rev') === 'true');
             menuElement.menu({ disabled: !isUmltLocked });
         }
     } else {
         //The current period is always unlocked
         menuElement.menu({ disabled: true });
     }
});

我准备了演示,为您演示如何在jqGrid内使用拆分按钮".它显示

I prepared the demo for you which demonstrates how Split Button can be used inside of jqGrid. It displays

我将在稍后发布的演示中进行更详细的说明.在检查了代码之后,您可能会了解所有内容.

More detailed explanation of the demo I'll post later. Probably you will understand all yourself after examining of the code.