实现以下效果
点跳转到demo后直接跳转到demo示例,并且带上查询条件,如下:
由于jeecg使用的是easyui,所以不能直接用类似于这样的方式来跳转了,但还是有办法做到的,首先在\plug-in\accordion\js\left_shortcut_menu.js中增加以下代码:
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 : '', 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 : '' } }); } $.messager.progress('close'); } // $('#maintabs').tabs('select',subtitle); tabclose();}
这个方法实际上基本上都是抄原来的addtab方法,就是在如果原来已经打开tab的情况下用update的方式来更新tab。
然后在需要跳转到其它页面的地方增加以下代码,以jeecgnotelist.jsp为例:
对应的js:
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方法对链接进行处理,否则如果链接中带有特殊字符如引号的话不处理是无法正常传递参数的。
然后在目标界面增加以下代码,以jeecgdemolist.jsp为例:
$(function() { init(); }); 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生成的,所以需要根据实际情况修改成实际的值。