easyUI menu动态添加

HTML代码:

<!-- 菜单 -->
	      <div id="mm" class="easyui-menu" style="width:140px;">  
      
            </div>  

Javascript代码:

/*绑定右键*/
                 $(".datagrid-cell").live('contextmenu',function(e){//.datagrid-cell 是easyUI表格样式,这样设置的原因是,让菜单在表格上点击右键才显示
                  var selectRow=$('#grid').datagrid('getSelected');//获得选中行数据
                     //显示快捷菜单
                     if(selectRow==null){
                      Ext.Msg.alert('提示', '请在表格上单击左键选择一行数据.');
                      return false;
                     }
                     //第一步将集合清空
                     $('#mm').empty();
                     //创建菜单
                     createMenu(selectRow);
                    // alert($('#mm').children().size());
                     //没有子菜单,那么不显示
                     if($('#mm').children().size()==0){
                    	 return false;
                     }
                   //菜单添加完毕显示菜单
                     $('#mm').menu('show', {
                         left: e.pageX,
                         top: e.pageY
                     });
                     return false;
                 });


创建菜单方法:

  //创建菜单
                 function createMenu(row){
                	    var tjlx = document.getElementById("tjlx").value; // 统计类型   年1  季度2  月3  日4
                		var collectType=document.getElementById("collectType").value;//统计方式  unit:按单位 Sections 按科室
                		var orgcode=row.orgcode;
                		var showtime=row.showtime;
                		var collectType=document.getElementById("collectType").value;//unit,按单位;Sections,按科室
                		var officecode="";
                		if(collectType=='Sections'){
                			   var officecode=row.officecode;
                		}
                		//if 01
               			if(collectType=="unit"){
						var dbyear=showtime.substring(0,4);//年度
						var exaTimeType="0";
						if(tjlx=="2"){
						var exaTimeType=showtime.substring(showtime.indexOf("年")+1,showtime.indexOf("季"));//季度
						}
						if(tjlx=="3"){
						var exaTimeType=showtime.substring(showtime.indexOf("年")+1,showtime.indexOf("月"));//月份
						}
					     //绑定点击事件
						  $('#mm').menu('appendItem',{id:"m_001",text:"按日期各科室分解"});
					      $("#m_001").click(function(){
					    	 openWin(orgcode,dbyear,tjlx,exaTimeType,officecode,"Sections");
					      });
						}
                		//if 01
                        //if 02
                       	if(tjlx=="1"){
							var dbyear=showtime.substring(0,4);//年度
							//添加点击事件,onclick:
							 $('#mm').menu('appendItem',{id:"m_002",text:"按日期各季度分解"});
							 $("#m_002").click(function(){
								 openWin(orgcode,dbyear,"2","0",officecode,collectType);
						      });
						}
                        //if 02
                        
                        //if 03
                        	//年 按照月度查询
						if(tjlx=="1")
						{
						var dbyear=showtime.substring(0,4);//年度
						//添加点击事件,onclick:
						$('#mm').menu('appendItem',{id:"m_003",text:"按日期各月份分解"});
						$("#m_003").click(function(){
							openWin(orgcode,dbyear,"3","0",officecode,collectType);
					      });
						}
                        //if 03
                        
                        //if 04
                        //季度按照月查询
						if(tjlx=="2"){	
						var dbyear=showtime.substring(0,4);//年度
						var exaTimeType=showtime.substring(showtime.indexOf("年")+1,showtime.indexOf("季"));//季度
						    var tempExaTimeType="";
							if(exaTimeType=="1")
							{
								tempExaTimeType="1,2,3";
							}
							if(exaTimeType=="2")
							{
								tempExaTimeType="4,5,6";
							}
							if(exaTimeType=="3")
							{
								tempExaTimeType="7,8,9";
							}
							if(exaTimeType=="4")
							{
								tempExaTimeType="10,11,12";
							}
							//添加点击事件,onclick:
							$('#mm').menu('appendItem',{id:"m_004",text:"按日期各月份分解"});
							$("#m_004").click(function(){
								openWin(orgcode,dbyear,"3",tempExaTimeType,officecode,collectType);
						      });
						}
                        //if 04
                   		
                		
                 }
                 




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值