JqGrid PHP: how to implement a righ-click context-menu?

喜你入骨 提交于 2020-01-17 15:04:18

问题


How can I implement a righ-click context-menu in JqGrid for PHP ?

I am trying this solution by Oleg, but it is not working. I would like to get this:


grid.php snippet:

$rightclick = <<<RIGHTCLICK
    function () {
    $("tr.jqgrow", this).contextMenu('myMenu1', {
        bindings: {
            'edit': function (trigger) {
                // trigger is the DOM element ("tr.jqgrow") which are triggered
                grid.editGridRow(trigger.id, editSettings);
            },
            'add': function ( /*trigger*/ ) {
                grid.editGridRow("new", addSettings);
            },
            'del': function (trigger) {
                if ($('#del').hasClass('ui-state-disabled') === false) {
                    // disabled item can do be choosed
                    grid.delGridRow(trigger.id, delSettings);
                }
            }
        },
        onContextMenu: function (event /*, menu*/ ) {
            var rowId = $(event.target).closest("tr.jqgrow").attr("id");
            //grid.setSelection(rowId);
            // disable menu for rows with even rowids
            $('#del').attr("disabled", Number(rowId) % 2 === 0);
            if (Number(rowId) % 2 === 0) {
                $('#del').attr("disabled", "disabled").addClass('ui-state-disabled');
            } else {
                $('#del').removeAttr("disabled").removeClass('ui-state-disabled');
            }
            return true;
        }
    });
}
RIGHTCLICK;

$grid->setGridEvent('loadComplete ', $rightclick);

Is there any way to get a context menu in JqGrid for PHP ?


回答1:


First of all your code have unneeded space: 'loadComplete ' instead of 'loadComplete'.

I can repeat one more time that I don't use PHP myself and don't use setGridEvent of JqGrid for PHP too. So I can only guess that $grid->setGridEvent probably don't forward this correctly. In the case you can use setGridParam to set callback dynamically (see the answer) or to use jqGridLoadComplete event instead of loadComplete callback (see the answer).



来源:https://stackoverflow.com/questions/21532308/jqgrid-php-how-to-implement-a-righ-click-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!