easyUI menu动态添加
生活随笔
收集整理的這篇文章主要介紹了
easyUI menu动态添加
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HTML代碼:
<!-- 菜單 --><div id="mm" class="easyui-menu" style="width:140px;"> </div>Javascript代碼:
/*綁定右鍵*/$(".datagrid-cell").live('contextmenu',function(e){//.datagrid-cell 是easyUI表格樣式,這樣設(shè)置的原因是,讓菜單在表格上點(diǎn)擊右鍵才顯示var selectRow=$('#grid').datagrid('getSelected');//獲得選中行數(shù)據(jù)//顯示快捷菜單if(selectRow==null){Ext.Msg.alert('提示', '請?jiān)诒砀裆蠁螕糇箧I選擇一行數(shù)據(jù).');return false;}//第一步將集合清空$('#mm').empty();//創(chuàng)建菜單createMenu(selectRow);// alert($('#mm').children().size());//沒有子菜單,那么不顯示if($('#mm').children().size()==0){return false;}//菜單添加完畢顯示菜單$('#mm').menu('show', {left: e.pageX,top: e.pageY});return false;});創(chuàng)建菜單方法:
//創(chuàng)建菜單function createMenu(row){var tjlx = document.getElementById("tjlx").value; // 統(tǒng)計(jì)類型 年1 季度2 月3 日4var collectType=document.getElementById("collectType").value;//統(tǒng)計(jì)方式 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 01if(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("月"));//月份}//綁定點(diǎn)擊事件$('#mm').menu('appendItem',{id:"m_001",text:"按日期各科室分解"});$("#m_001").click(function(){openWin(orgcode,dbyear,tjlx,exaTimeType,officecode,"Sections");});}//if 01//if 02if(tjlx=="1"){var dbyear=showtime.substring(0,4);//年度//添加點(diǎn)擊事件,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);//年度//添加點(diǎn)擊事件,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";}//添加點(diǎn)擊事件,onclick:$('#mm').menu('appendItem',{id:"m_004",text:"按日期各月份分解"});$("#m_004").click(function(){openWin(orgcode,dbyear,"3",tempExaTimeType,officecode,collectType);});}//if 04}總結(jié)
以上是生活随笔為你收集整理的easyUI menu动态添加的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 最近QQ联系我解决问题的郁闷
- 下一篇: 全面讲述linux集群负载均衡