asp.net mvc - JQGrid ContextMenu - Dynamic Menus -


i have page, used building queries , running them against different entities (kind of query builder/generic search).

the results displayed in jqgrid, same grid used rendering results different entities.

this results grid has support context menus, differ each entity. need way change context menu per entity. each entity may have different number of menu items in context menu , each item may respond in different manner (sometimes alert, action spawning in different tab).

rendering different menus (through li) not issue attaching methods li proving challenge. pointers highly appreciated.

i using jquery.contextmenu-ui.js .

following sample picked (jqgrid) site

function initgrid() {     $("#entitygrid").contextmenu('cmenu'         ,{         bindings: { /* avoid , pass actions 1 method*/             'edit': function (t) {                 editrow();             },             'add': function (t) {                 addrow();             },             'del': function (t) {                 delrow();             }         },         oncontextmenu: function (event, menu) {             var rowid = $(event.target).parent("tr").attr("id")             var grid = $("#entitygrid");             grid.setselection(rowid);             return true;         }     }     ); } 

thanks, avinash

you can use onshowmenu callback of contextmenu instead of static binding using bindings. in same way menuid used first parameter of contextmenu id of dynamically created div empty <ul>. onshowmenu has form

onshowmenu: function (e, $menu) {     // here 1 can clear `<ul>` child of $menu     // , append "<li>" items     return $menu; } 

in the answer find example of code build menu dynamically.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -