Hi,
Depending of field value I'd like to have different context menus for records in DataGrid
How can I recreate already created menu or update existing one?
Now I have this:
onRowContextMenu: function(e, rowIndex, rowData){
e.preventDefault();
$(this).datagrid('unselectAll');
$(this).datagrid('selectRow', rowIndex);
if (!$('#tmenu').length){
var tmenu = $('<div id="tmenu" style="width:120px;"></div>').appendTo('body');
$('<div />').html('Edit').appendTo(tmenu);
$('<div />').html('Import').appendTo(tmenu);
$('<div />').html('Lock').appendTo(tmenu);
$('<div />').html('Unlock').appendTo(tmenu);
$('<div />').html('Activate').appendTo(tmenu);
$('<div />').html('Deactivate').appendTo(tmenu);
$('<div />').html('Clear').appendTo(tmenu);
tmenu.menu({
onClick: function(item){
// do smth
}
});
}
if(rowData.state=='Open'){
// update menu for record with is 'Open'
}
if(rowData.state=='Locked'){
// update menu for record with is 'Locked'
}
if(rowData.state=='Inactive'){
// update menu for record with is 'Inactive'
}
$('#tmenu').menu('show', {
left:e.pageX,
top:e.pageY
});
}