实现如下效果java
点"跳转到demo"后直接跳转到demo示例,而且带上查询条件,以下:json
因为jeecg使用的是easyui,因此不能直接用相似于<a href="xxxx.do?xxx">这样的方式来跳转了,但仍是有办法作到的,首先在\plug-in\accordion\js\left_shortcut_menu.js中增长如下代码:jsp
function goToTab(subtitle, url, icon) { // begin author:屈然博 2013-7-12 for:解决firefox 点击一次请求两次的问题 var progress = $("div.messager-progress"); if(progress.length){return;} // begin author:屈然博 2013-7-12 for:解决firefox 点击一次请求两次的问题 rowid=""; $.messager.progress({ text : loading, interval : 200 }); if (!$('#maintabs').tabs('exists', subtitle)) { //判断是否进行iframe方式打开tab,默认为href方式 if(url.indexOf('isHref') != -1){ $('#maintabs').tabs('add', { title : subtitle, href : url, closable : true, icon : icon }); }else{ $('#maintabs').tabs('add', { title : subtitle, content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>', closable : true, icon : icon }); } } else { $('#maintabs').tabs('select', subtitle); if(url.indexOf('isHref') != -1){ $('#maintabs').tabs('update', { tab : $('#maintabs').tabs('getSelected'), options : { href : url } }); } else { $('#maintabs').tabs('update', { tab : $('#maintabs').tabs('getSelected'), options : { content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>' } }); } $.messager.progress('close'); } // $('#maintabs').tabs('select',subtitle); tabClose(); }
这个方法实际上基本上都是抄原来的addTab方法,就是在若是原来已经打开tab的状况下用update的方式来更新tab。ui
而后在须要跳转到其它页面的地方增长如下代码,以jeecgNoteList.jsp为例:this
<t:dgFunOpt funname="toDemo(id)" title="跳转到demo" />
对应的js:url
function toDemo() { var url = "jeecgDemoController.do?jeecgDemo&selectedParams=" + encodeURIComponent("{\"sex\":0,\"createDate_begin\":\"2015-03-28\",\"createDate_end\":\"2015-04-14\"}"); window.parent.goToTab('Demo示例',url,'default') }
注意要用encodeURIComponent方法对连接进行处理,不然若是连接中带有特殊字符如引号的话不处理是没法正常传递参数的。firefox
而后在目标界面增长如下代码,以jeecgDemoList.jsp为例:code
$(function() { //延迟200毫秒执行,不然easyui会加载两次数据 setTimeout(init, 200); }); function init() { //alert($('#jeecgDemoList')); var href = decodeURIComponent(window.location.href); //alert(href); var idx = href.indexOf('selectedParams'); if (idx != -1) { idx = href.indexOf("{", idx); if (idx != -1) { var endIdx = href.indexOf("}", idx); if (endIdx != -1) { var selectedParams = href.substring(idx, endIdx + 1); var jsonParam = $.parseJSON(selectedParams); $('#jeecgDemoListtb').find('*').each(function() { if (jsonParam[$(this).attr('name')] != undefined) { if ($(this)[0].tagName == "SELECT") { //$(this).attr("value", "0"); $(this).val(jsonParam[$(this).attr('name')]); } else if ($(this)[0].tagName == "INPUT") { $(this).val(jsonParam[$(this).attr('name')]) } } }); } } } jeecgDemoListsearch(); }
注意其中的jeecgDemoList相似的字眼由于是jeecg生成的,因此须要根据实际状况修改为实际的值。get