I am trying to create a context menu on jqGrid (for each row) but can't find how to do so.I am currently using jQuery Context Menu (is there a better way? )but it is for the entire Grid not for a particular row i.e. cannot perform row level operations for it. Please help me in this, thanks.
$(document).ready(function(){
$("#list1").jqGrid({
sortable: true,
datatype: "local",
height: 250,
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:50, sortable:false}
],
multiselect: true,
rowNum:10,
rowList:[10,20,30],
pager: '#pager1',
sortname: 'id',
recordpos: 'left',
viewrecords: true,
sortorder: "desc",
caption: "Manipulating Array Data"
});
$("#list1").jqGrid('navGrid','#pager1',{add:false,del:false,edit:false,position:'right'});
$("#list1").contextMenu({
menu: "myMenu"
},
function(action, el, pos) {
alert(
"Action: " + action + "
" +
"Element ID: " + $(el).attr("id") + "
" +
"X: " + pos.x + " Y: " + pos.y + " (relative to element)
" +
"X: " + pos.docX + " Y: " + pos.docY+ " (relative to document)"
);
});
See Question&Answers more detail:
os