Custom values to Context Menu Items in JQgrid contains great sample about adding context menu to jqgrid. If edit,delete, add operations are dynamically disabled, synching context menu with toolbar requires additional coding.
How to create context menu automatically from jqgrid top level toolbar so that additional coding is not required? Context menu should contain toolbar buttons icons and button titles become menu item titles. Selection menu triggers toolbar button click event.
Or if this is not possible, how to sync context menu items with toolbar? Fox example, if navtoolbar call has del:false , Delete command in context menu should not appear or appear disabled.
My new demo demonstrate how to do this:
In the demo I use small modification of the
jquery.contextmenu.js
included in the plugins directory of jqGrid. My code is far to be perfect especially in usage of CSS classes and getting colors used inmenuStyle
anditemHoverStyle
of thecontextMenu
. Nevertheless the code do want we need.The main part of the demo consist from
createContexMenuFromNavigatorButtons
function which can be called after the navigator bar are build (afternavGrid
andnavButtonAdd
). The usage is very simple:The code of
createContexMenuFromNavigatorButtons
you will find below: