Custom values to Context Menu Items in JQgrid

若如初见. 提交于 2019-11-29 17:41:46

You can use trigger parameter which has id initialized as the rowid. So you can use getCell or getRowData. For example the abc1 method can be like the following

loadComplete: function () {
    var $this = $(this); // it will be the same like $("#grid")
    $("tr.jqgrow", this).contextMenu('contextMenu', {
        bindings: {
            abc1: function(trigger) {
                var rowData = $(this).jqGrid('getRowData', trigger.id);
                // now you can access any data from the row including
                // hidden columns with the syntax: rowData.colName
                // where colName in the value of 'name' property of
                // the column
            },
            ...
        },
        onContextMenu : function(event, menu) {
            ...
        },
        // next settings 
        menuStyle: {
            backgroundColor: '#fcfdfd',
            border: '1px solid #a6c9e2',
            maxWidth: '600px', // to be sure
            width: '100%' // to have good width of the menu
        },
        itemHoverStyle: {
            border: '1px solid #79b7e7',
            color: '#1d5987',
            backgroundColor: '#d0e5f5'
        }
    });

see here one more demo which uses menuStyle and itemHoverStyle which improve a little the visibility of the context menu. The demo is from the bug request which I recently posted.

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