You have to detect if the 'row' parameter is null in the 'onContextMenu' function.
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