EasyUI Forum

General Category => Bug Report => Topic started by: what_tahw on October 11, 2015, 09:07:57 PM



Title: context menu issue in treegrid and datagrid (ver 1.4.3)
Post by: what_tahw on October 11, 2015, 09:07:57 PM
in 1.4.3 version, when right click inside treegrid/datagrid control, but outside data rows, would trigger context menu.
but at that time, id is "null",
so we might got this error message: "Uncaught TypeError: Cannot read property 'id' of null"


Title: Re: context menu issue in treegrid and datagrid (ver 1.4.3)
Post by: jarry on October 11, 2015, 11:54:51 PM
You have to detect if the 'row' parameter is null in the 'onContextMenu' function.
Code:
function onContextMenu(e,row){
if (row){
e.preventDefault();
$(this).treegrid('select', row.id);
$('#mm').menu('show',{
left: e.pageX,
top: e.pageY
});
}
}

Please refer to http://www.jeasyui.com/demo/main/index.php?plugin=TreeGrid&theme=default&dir=ltr&pitem=TreeGrid%20ContextMenu