jquery - jqGrid - determine name of column on right click of a cell in jqGrid -
so have column name when open context menu opens on right click on cell in table. found answer jqgrid - determine name of column on right click of column in jqgrid, column headers.
my code far
loadcomplete: function () { $('tr.jqgrow').contextmenu('mymenu2', { bindings: { ca: function(trigger) { var cm = $('#' + my_grid ).jqgrid("getgridparam", "colmodel"); //code should added here -- column name , pass addtocontext(); var rowdata = jquery('#' + my_grid ).jqgrid ('getrowdata', trigger.id); addtocontext(rowdata); } } }); },
also tried code undefined
var cellname = $(trigger).closest('td').attr('aria-described-by');
you can use oncontextmenu determine column name using aria-describedby attrinute this
....contextmenu('contextmenu', { bindings: { 'edit': function (t,c) { console.log(colname) editrow(); }, 'add': function (t) { addrow(); }, 'del': function (t) { delrow(); } }, oncontextmenu: function (event) { colname = $(event.target).attr('aria-describedby'); colname = colname.substr(gridid.length + 1); return true; } });
where colname defind globally , gridid id of grid without #
p.s. in case of complex content in cell correct replace
$(event.target).attr('aria-describedby');
with
$(event.target).closest('td').attr('aria-describedby');
Comments
Post a Comment