jquery-easyui 动态树

首选在jsp页面中引入相关的js

<link rel="stylesheet" type="text/css" href="<%=path %>/css/jquery_easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=path %>/css/jquery_easyui/themes/icon.css">
	<script type="text/javascript" src="<%=path %>/js/jquery_easyui/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="<%=path %>/js/jquery_easyui/jquery.easyui.min.js"></script>

添加script

	<script>
			$(function(){
			$('#tt2').tree({
				checkbox: false,
				url: '<%=path%>/formconfig/loadWfNodes.do',
				onBeforeExpand: function(node){
				  $('#tt2').tree('options').url = '<%=path%>/formconfig/loadWfNodes.do?wfId='+node.id;
				}
			});
		});
	</script>


 

在body中加入

 <body> 
		<ul id="tt2">
		<li state="closed" id='0'><span>流程列表</span></li>
		</ul>
  </body>


后台拼接json数据

package com.aegon_cnooc.oa.formconfig.action;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.aegon_cnooc.framework.base.action.BaseAction;
import com.aegon_cnooc.oa.formconfig.service.FormConfigService;
import com.aegon_cnooc.oa.ibatis.to.TuOafWfTO;
import com.aegon_cnooc.oa.ibatis.to.TuOafWfnodesTO;
import com.aegon_cnooc.util.StringUtil;
/**
 * 加载流程下的节点的名称
 * @Author: liuxinghui
 * @Date: 2011-9-8
 * @Version: 2.0
 * @Despcrition:
 */
public class LoadWfNodesAction extends BaseAction{
	private FormConfigService formConfigService;
	public ActionForward executeAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String wfId=request.getParameter("wfId");
		String jsonstr = "[";
		if(StringUtil.isNotEmpty(wfId)&&"0".equals(wfId)){
			
			List wfList=formConfigService.findWf();
			for(int i=0;i<wfList.size();i++){
				TuOafWfTO wfTo=(TuOafWfTO)wfList.get(i);
			jsonstr=jsonstr+
				"{\n" +
				"    \"id\":"+wfTo.getWfid()+",\n" + 
				"    \"text\":\"<a href='javaScript:void(0)' target='mainFrame'>"+wfTo.getWfname()+"</a>\",\n" + 			
				"    \"state\":\"closed\"\n" + 
				"  },";
			}
			int end=jsonstr.length()-1;//去掉最后一个逗号
			String json=jsonstr.substring(0,end);
			json=json+"]";
		response.setContentType("application/json;charset=gbk");
		response.setCharacterEncoding("gbk");
		PrintWriter pw = response.getWriter();
		pw.write(json);
		pw.flush();
		}else{
		List wfNodes=formConfigService.findWfNodesById(wfId);
			for(int i=0;i<wfNodes.size();i++){
				TuOafWfnodesTO wfNodesTo=(TuOafWfnodesTO)wfNodes.get(i);
			jsonstr=jsonstr+
				"{\n" +
				"    \"id\":"+wfNodesTo.getNodeid()+",\n" + 
				"    \"text\":\"<a href='" + request.getContextPath()+
				"/formconfig/loadGroupByWfIdAndNodeId.do?wfId="+wfId+"&nodeId="+wfNodesTo.getNodeid()+"' target='mainFrame'>"+wfNodesTo.getGenstepname()+"("+wfNodesTo.getNodeid()+")</a>\",\n" + 		
				"    \"state\":\"closed\"\n" + 
				"  },";
			}
			int end=jsonstr.length()-1;//去掉最后一个逗号
			String json=jsonstr.substring(0,end);
			json=json+"]";
		response.setContentType("application/json;charset=gbk");
		response.setCharacterEncoding("gbk");
		PrintWriter pw = response.getWriter();
		pw.write(json);
		pw.flush();
		}
		return null;
	}
	public void setFormConfigService(FormConfigService formConfigService) {
		this.formConfigService = formConfigService;
	}

}


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面。开发者不需要编写复杂的javascript,也不需要对css样式有深入的了解,开发者需要了解的只有一些简单的html标签 1.3.6更新 Bug treegrid: getChecked方法不能返回正确的行. fixed. tree: 异步,在onlyLeafCheck:true时复选框不显示正确. fixed. Improvement treegrid:继承datagrid组件所有的selecting和checking方法。 linkbutton:图标对齐方式,支持值:'top','bottom','left','right'。 linkbutton:添加"size"属性,支持值:'small','large'。 linkbutton:添加的onClick事件。 menubutton:添加"menuAlign"属性,允许用户设置顶级菜单对齐。 combo:添加"panelAlign"属性,支持值:'left','right'。 calendar:"formatter"、"styler"和"validator"选项可用于自定义日历日期。 calendar:添加的onChange事件。 panel:添加"method","queryParams"和"loader"属性。 panel:添加"onLoadError"事件。 datagrid:添加"onBeginEdit"事件。 datagrid:添加"onEndEdit"事件。 datagrid:添加"sort"方法和"onBeforeSortColumn"事件。 datagrid:"combogrid"编辑器集成到datagrid。 datagrid:添加"ctrlSelect"属性,允许使用ctrl+click 多选 slider:添加"converter"选项,允许用户决定如何将一个值转换为滑块的位置或滑块位置值。 searchbox:添加"disabled"属性。 searchbox:添加"disabled","enable","clear","reset"方法。 spinner:添加"readonly"属性、"readonly"方法和"onChange事件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值