作者:问晓 | 来源:互联网 | 2022-01-26 01:24
在上篇文章给大家介绍了jquery中EasyUI实现异步树,本文给大家介绍jquery easyui实现动态树。
首先是在jsp页面中引入相关的js文件
在body中加入流程列表,通过后天拼接json数据
具体内容请看下面代码详情吧。
首选在jsp页面中引入相关的js
/css/jquery_easyui/themes/default/easyui.css">
/css/jquery_easyui/themes/icon.css">
添加script
在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"+wfTo.getWfname()+"\",\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"+wfNodesTo.getGenstepname()+"("+wfNodesTo.getNodeid()+")\",\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;
}
}
下面一段代码是EasyUI Jquery 动态加载树,点击节点加载