J’utilise ce lien depuis Oleg et Demo pour créer un menu contextuel. Existe-t-il un moyen de transmettre des valeurs dynamics à chaque ligne en dehors de rowId. Une solution consiste peut-être à définir des valeurs masquées pour chaque ligne et à obtenir ces valeurs de colonne masquées sans savoir comment implémenter cette fonctionnalité. Merci pour toute aide ou suggestion ..
loadComplete: function(data) { // Fix the Grid Width... fixGridWidth($("#grid")); // Context Menu $("tr.jqgrow", this).contextMenu('contextMenu', { bindings: { 'abc1': function(sortinggger) { // would like to pass some custom values }, 'abc2': function(sortinggger) { // open a link in new window using a hyperlink }, 'abc3': function(sortinggger) { // custom logic } }, onContextMenu : function(event, menu) { //var rowId = $(event.target).parent("tr").attr("id"); //var grid = $("#grid"); //grid.setSelection(rowId); //return true; } });
Vous pouvez utiliser sortinggger
paramètre de sortinggger
dont l’ id
est initialisé en tant que rowid Vous pouvez donc utiliser getCell
ou getRowData
. Par exemple, la méthode abc1
peut être comme suit
loadComplete: function () { var $this = $(this); // it will be the same like $("#grid") $("tr.jqgrow", this).contextMenu('contextMenu', { bindings: { abc1: function(sortinggger) { var rowData = $(this).jqGrid('getRowData', sortinggger.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' } });
voir ici une autre démo qui utilise menuStyle
et itemHoverStyle
qui améliorent un peu la visibilité du menu contextuel. La démo provient de la demande de bogue que j’ai récemment postée.