为lazyTreeGrid添加右键菜单

在完成个人任务显示的时候需要 为lazyTreeGrid添加右键菜单,而lazyTreeGrid不支持右键菜单,但是在看lazyTreeGrid.js的时候发现它是继承的TreeGrid.js,treeGrid.js继承的dataGrid.js,而dataGrisd是可以使用右键菜单的。

设置grid的为lazyTreeGrid,为其设置相关属性,不过这里面没有与右键菜单有关的属性。

<div id="gridDiv3" style="display: none;font-size:12px;height:100%;" dojoType="dojox.grid.LazyTreeGrid" 
	treeModel="DG.treeModel1" canSort=false expendoCell ="0" colSpans="{0: [{start: 1,end: 20,primary: 12}]}"
	structure="DG.mixedWorkItemslayout" rowSelector="0px" escapeHTMLInData=false>
</div>


右键弹出的菜单

<div dojoType="dijit.Menu" id="gridMenu" style="display: none;" >
	<div id="openMenuItem" onClick="Menu.openTask" dojoType="dijit.MenuItem" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" style="height: 24px !important;">打开任务</div>
<!-- 	<div dojoType="dijit.MenuSeparator"></div> -->
	<div id="historyMenuItem" onClick="Menu.showTaskHistory" dojoType="dijit.MenuItem" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" style="height: 24px !important;" >任务历史</div>
	<div id="launchWorkflowMenuItem" onClick="launchWorkflowByCopy" dojoType="dijit.MenuItem" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" style="height: 24px !important" >复制发起新任务</div>
	<!--div dojoType="dijit.MenuSeparator"></div>  -->
	<div id="classifyMenuItem" onClick="Menu.showClassifyDlg" disabled= true dojoType="dijit.MenuItem" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" style="height: 24px !important" >任务分类</div>
	<div id="deleteClassifyMenuItem" onClick="Menu.deleteClassifyItem" disabled= true dojoType="dijit.MenuItem" style="height: 24px !important"onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'">从分类中移除任务</div>
	<!--div dojoType="dijit.MenuSeparator"></div> -->
	<div id="recallTaskMenuItem" onClick="Menu.recallTaskApplication();" dojoType="dijit.MenuItem" style="height: 24px !important" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" disabled= true>召回申请</div>
    <!--div dojoType="dijit.MenuSeparator"></div>-->
    <div id="lockMenuItem" onClick="Menu.lockTask" dojoType="dijit.MenuItem" style="height: 24px !important" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'"  disabled= true>任务加锁</div>
    <div id="unlockMenuItem" onClick="Menu.unlockTask" dojoType="dijit.MenuItem" style="height: 24px !important" onmouseover="this.className='gridMenuCssOver'" onmouseout="this.className='gridMenuCssOut'" disabled= true >任务解锁</div>
</div>



在所有控件ready的时候为grid3加载属性

dojo.ready( function() {        
        var grid3 = dijit.byId("gridDiv3");
	window["gridMenu"] = dijit.byId("gridMenu");
	var gridMenu = dijit.byId("gridMenu");
	gridMenu.bindDomNode(grid3.domNode);
	grid3.onCellContextMenu = function(e){
		//右键选中
		grid3.selection.select(e.rowIndex);
		//确定右键弹出菜单的各种情况
		DG.setGridMenuStatus();
		cellNode = e.cellNode;
	};
          });


最后效果为

为lazyTreeGrid添加右键菜单_第1张图片

你可能感兴趣的:(为lazyTreeGrid添加右键菜单)