treegrid-3.0范例:动态加载数据、右键菜单等

范例:动态加载数据、右键菜单等

<input type="button" value="刷新" onclick="_refresh()">
<br><br><textarea id="currentRow" rows="4" cols="100"></textarea>
<br><br><div id="div1" style="width:850px;"></div>

 

<script language="javascript">
	var config = {
		"show_summary": true,
		"chk_show": true,
		chk_cascade_select_children: true,
		chk_cascade_select_parent: true,
		"id_field": "id",
		"dataurl": "org/getChildrens",
		"columns":[
			{"title": "组织名称", "field": "orgName"},
			{"title": "组织编号", "field": "orgCode", "align": "center", "width": "60"},
			//{"title": "描述", "field": "orgDesc", "align": "center", "width": "100"},
			{"title": "操作人", "field": "operator", "align": "center", "width": "50"},
			{"title": "总人数", "field": "count", "align": "center", "width": "50", "defaultValue": "0", "fieldCal": true, "calStyle": "sum"},
			{"title": "薪水", "field": "salary", "align": "center", "width": "50", "defaultValue": "0.0", "fieldCal": true, "calStyle": "avg", digit: 2},
			{"title": "操作日期", "field": "operateTime", "align": "center", "width": "70"},
			{"title": "进度", "width": "100", "handler": "jdHandler"},
			{"title": "操作", "width": "100", "handler": "operateHandler", "align": "center"}
		],
		"menus":[
			{"title": "展开节点", "url": "http://www.163.com?id=#id#&orgCode=#orgCode#", "target": "_blank"},
			{"title": "折叠节点", "url": "http://www.163.com?2", "target": "_self"},
			{"title": "删除节点", "url": "http://www.163.com?3", "target": "_blank"},
			{"title": "刷新"}
		]
	};
	
	//方法返回单元格的自定义显示内容
	function jdHandler(trid, fieldValue, rowdata, colMeta){
		var n = Math.floor(Math.random()*(100-1))+1;
		return "<div style=\"width:" + n + ";background:red;height:100%;\">" + n + "</div>";
	}
	
	function operateHandler(trid, fieldValue, rowdata, colMeta){
		var s = "";
		s += "<a href='javascript:void(0)' style='color:blue'>查看</a>&nbsp;&nbsp;";
		s += "<a href='javascript:void(0)' style='color:blue'>编辑</a>&nbsp;&nbsp;";
		s += "<a href='javascript:void(0)' style='color:blue'>删除</a>";
		return s;
	}

	var treeGrid = jQuery("#div1").showTreeGrid(config);
	
	function _refresh(){
		treeGrid.show();
	}
</script>

 
treegrid-3.0范例:动态加载数据、右键菜单等_第1张图片
 

String parent_id = request.getParameter("parent_id");
		
if(StringUtil.isEmpty(parent_id)) {
	parent_id = "0";
}

List<Organizations> list = organizationsService.selectByParentId(new Long(parent_id));
String result = JSONArray.fromObject(object).toString();
return result;

 

[{"count":3,"id":4,"operateTime":"2015-12-01","operator":"","orgCode":"FG","orgDesc":"","orgName":"佛冈分公司","parentOrgId":0,"salary":1,"status":1},{"count":2,"id":1,"operateTime":"2015-12-01","operator":"","orgCode":"CQ","orgDesc":"","orgName":"城区分公司","parentOrgId":0,"salary":5,"status":1},{"count":7,"id":2,"operateTime":"2015-12-01","operator":"","orgCode":"QX","orgDesc":"","orgName":"清新分公司","parentOrgId":0,"salary":5,"status":1},{"count":6,"id":3,"operateTime":"2015-12-01","operator":"","orgCode":"YD","orgDesc":"","orgName":"英德分公司","parentOrgId":0,"salary":5,"status":1}]

 

你可能感兴趣的:(treegrid-3.0范例:动态加载数据、右键菜单等)