treegrid-3.0范例:设置静态数据集
范例:设置静态数据集
<input type="button" value="更新数据集" onclick="updateDataset()"> <br><br><textarea id="currentRow" rows="4" cols="100"></textarea> <br>行单击事件、行双击事件、字段默认显示值 <br><br><div id="div1" style="width:850px;"></div>
<script language="javascript"> //双击数据行触发该事件方法 var onDblClickRow = function(id, index, data){ jQuery("#currentRow").val("onDblClickRow: " + id + "," + index + "," + data.orgName); } var config = { "show_summary": true, "columns":[ {"title": "组织名称", "field": "orgName"}, {"title": "组织编号", "field": "orgCode", "align": "center", "width": "60"}, {"title": "描述", "field": "orgDesc", "align": "center", "width": "100"}, {"title": "操作人", "field": "operator", "align": "center", "width": "60"}, {"title": "总人数", "field": "count", "align": "center", "width": "60", "defaultValue": "0", "fieldCal": true, "calStyle": "sum"}, {"title": "薪水", "field": "salary", "align": "center", "width": "60", "defaultValue": "0.0", "fieldCal": true, "calStyle": "avg"} ], onClickRow: function(id, index, data){ //单击数据行触发该事件方法 jQuery("#currentRow").val("onClickRow: " + id + "," + index + "," + data.orgName); }, onDblClickRow: onDblClickRow }; var treeGrid = jQuery("#div1").showTreeGrid(config); function updateDataset(){ var ds = [ {"id": 1,"orgName": "城区分公司", "orgCode": "CQ", "operator": "cjm", "children":[]}, {"id": 2,"orgName": "清新分公司", "orgCode": "QX", "operator": "", "children":[]}, {"id": 3,"orgName": "英德分公司", "orgCode": "YD", "operator": "", "children":[]}, {"id": 4,"orgName": "佛冈分公司", "orgCode": "FG", "operator": "", "children":[ {"id": 7,"orgName": "chlid1", "count": 30, "salary": 1000.00}, {"id": 8,"orgName": "chlid2", "count": 20, "salary": 900.00} ]} ]; treeGrid.setDataset(ds); treeGrid.show(); } </script>
相关推荐
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
85477104 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04
wwwjun 2020-11-02
gyunwh 2020-11-02
EchoYY 2020-10-31
dingyahui 2020-10-30