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

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

<input type="button" value="刷新" οnclick="_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>

 

 

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}]

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值