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>

 
treegrid-3.0范例:设置静态数据集
 

相关推荐