Heim  >  Artikel  >  Web-Frontend  >  jeecg3.5中实现从一个页面跳转到另一个页面_html/css_WEB-ITnose

jeecg3.5中实现从一个页面跳转到另一个页面_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:14:042623Durchsuche

实现以下效果

点"跳转到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 : '<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。

然后在需要跳转到其它页面的地方增加以下代码,以jeecgNoteList.jsp为例:

<t:dgFunOpt funname="toDemo(id)" title="跳转到demo" />

对应的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生成的,所以需要根据实际情况修改成实际的值。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn