jqGrud树形表格+树形菜单+底部合计+点击列可编辑

该博客介绍了如何利用jqGrid库创建具备树形结构、底部总计以及点击列即可编辑功能的表格。同时,也涵盖了树形菜单的实现,提供了一种高效的数据展示和编辑解决方案。
摘要由CSDN通过智能技术生成

树形表格+底部合计+点击列可编辑 


<form id="controlNum_sgjf_list_form" class="form-horizontal" method="post" enctype="multipart/form-data">
	<table class="bs_table" id="controlNum_sgjf_list_table"></table>
	<div id="controlNum_sgjf_list_num_table"></div>
</form>
<script type="text/javascript">
$(function(){
	var xmzt='1';
	var changeId="";
	saveparameters = {
			"successfunc" : null,
			"url" : 'clientArray',
			"extraparam" : {},
			"aftersavefunc" : null,
			"errorfunc": null,
			"afterrestorefunc" : null,
			"restoreAfterError" : true,
			"mtype" : "POST"
	};
	var $tableC = $("#controlNum_sgjf_list_table");
	$tableC.jqGrid({
		url:path+"/xmk/sanGongControlNumController/getSanGongControlNum.do",
		ExpandColumn:"INCODE",  // 指定某列用于展开表格 
		height:"auto", //高度自适应
		rowNum : "-1",  
		scrollrows:true,
		treeGrid:true,
		shrinkToFit : false,
		autowidth: true,
		treedatatype:"json",
		treeGridModel:"adjacency", //treeGrid模式,跟json元数据有关 ,adjacency/nested  
		loadonce:true,
		ExpandColClick:true,
		treeReader:{
			"parent_id_field":"PARENT_ID",
			"level_field":"ORG_LEVEL",  // 树的等级根节点为0,依次递增
			"leaf_field":"isLeaf",  // 是否是子节点
			"expanded_field":"expanded",  // 是否展开 
			"loaded":"loaded", //是否异步加载
 			"icon_field":"icon",
			"sort_field":"INCODE"  //指定字段排序
		},
		datatype:"json",
		styleUI : 'Bootstrap', 
		postData:{ywzt:xmzt},
		colModel:[
			{name:'ID',label:'ID',index:'ID', hidden:true,key:true,frozen: true,editable:true},
			{name:"INCODE",label:"单位编码",index:"INCODE"},
			{name:"NAME",label:"单位名称",index:"INCODEORNAME",align:'center'},
			{name:"XYJE",label:"现有金额",index:"XYJE",align:'center',formatter:function(value,options,row){return formatCurrency(value);}},
			{name:"SGJFKZJE",label:"控制金额",index:"SGJFKZJE",align:'center',editable:true,formatter:function(value,options,row){return formatCurrency(value);}},
			{name:"YEAR",hidden:true,label:"年度",index:"YEAR",align:'center'},
			${ysndlb}
			{name:"KZREMARK",label:"控制说明",index:"KZREMARK",align:'center',editable:true},
			{name:"BZ",label:"备注",index:"BZ",editable:true,align:'center'},
		],
		footerrow: true,//是否显示表尾行,表尾是一空白行
		gridComplete: completeMethod,//底部合计列
		useFooter : true,
//		userDataOnFooter: true,//是否将返回来的表尾数
treegrid插件 当前选中的行: var config = { id: "tg1", width: "800", renderTo: "div1", headerAlign: "left", headerHeight: "30", dataAlign: "left", indentation: "20", folderOpenIcon: "images/folderOpen.gif", folderCloseIcon: "images/folderClose.gif", defaultLeafIcon: "images/defaultLeaf.gif", hoverRowBackground: "false", folderColumnIndex: "1", itemClick: "itemClickEvent", columns:[ {headerText: "", headerAlign: "center", dataAlign: "center", width: "20", handler: "customCheckBox"}, {headerText: "名称", dataField: "name", headerAlign: "center", handler: "customOrgName"}, {headerText: "拼音码", dataField: "code", headerAlign: "center", dataAlign: "center", width: "100"}, {headerText: "负责人", dataField: "assignee", headerAlign: "center", dataAlign: "center", width: "100"}, {headerText: "查看", headerAlign: "center", dataAlign: "center", width: "50", handler: "customLook"} ], data:[ {name: "城区分公司", code: "CQ", assignee: "", children:[ {name: "城区卡品分销中心"}, {name: "先锋服务厅", children:[ {name: "chlid1"}, {name: "chlid2"}, {name: "chlid3", children: [ {name: "chlid3-1"}, {name: "chlid3-2"}, {name: "chlid3-3"}, {name: "chlid3-4"} ]} ]}, {name: "半环服务厅"} ]}, {name: "清新分公司", code: "QX", assignee: "", children:[]}, {name: "英德分公司", code: "YD", assignee: "", children:[]}, {name: "佛冈分公司", code: "FG", assignee: "", children:[]} ] }; /* 单击数据行后触发该事件 id:行的id index:行的索引。 data:json格式的行数据对象。 */ function itemClickEvent(id, index, data){ window.location.href="ads"; } /* 通过指定的方法来自定义栏数据 */ function customCheckBox(row, col){ return ""; } function customOrgName(row, col){ var name = row[col.dataField] || ""; return name; } function customLook(row, col){ return "查看"; } //创建一个组件对象 var treeGrid = new TreeGrid(config); treeGrid.show(); /* 展开、关闭所有节点。 isOpen=Y表示展开,isOpen=N表示关闭 */ function expandAll(isOpen){ treeGrid.expandAll(isOpen); } /* 取得当前选中的行,方法返回TreeGridItem对象 */ function selectedItem(){ var treeGridItem = treeGrid.getSelectedItem(); if(treeGridItem!=null){ //获取数据行属性值 //alert(treeGridItem.id + ", " + treeGridItem.index + ", " + treeGridItem.data.name); //获取父数据行 var parent = treeGridItem.getParent(); if(parent!=null){ //jQuery("#currentRow").val(parent.data.name); } //获取子数据行集 var children = treeGridItem.getChildren(); if(children!=null && children.length>0){ jQuery("#currentRow").val(children[0].data.name); } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值