TreeGrid是树形表格,为了展示成树形,比数据表格主要增加了以下两点;

1、表格属性中设置 idField、treeField 两个属性;idField 表示用于区分上下级的主键,treeField 表示展开、关闭下级的字段;

2、获取的数据中新增属性:_parentId、state;_parentId 表示当前行的父节点 idField 值,state表示展开、关闭 的默认状态

_parentId

  • 如果是顶级节点,则必须为null值,或者将该属性delete掉,否则数据不能正常显示;

state

  • 'open' :默认该节点是打开的 ,如果加载本节点的时候没有加载子节点并且为 'open',则以后也不会加载子节点;
  • 'closed':默认该节点是关闭的,展开该节点时,如果下级数据随本级数据一起加载,数据就展示下级,没有下级数据则自动请求服务器加载数据。

数据格式如下:

{"total":null,"rows":[{"OID":"522300000000","SHORT_NAME":"黔西南州","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520300000000","SHORT_NAME":"遵义市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520100000000","SHORT_NAME":"贵阳市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520200000000","SHORT_NAME":"六盘水市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520500000000","SHORT_NAME":"毕节市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"522700000000","SHORT_NAME":"黔南州","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520600000000","SHORT_NAME":"铜仁市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520400000000","SHORT_NAME":"安顺市","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"522600000000","SHORT_NAME":"黔东南州","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520700000000","SHORT_NAME":"贵安新区","AREA_LEVEL":1,"_parentId":"520000000000","state":"closed"},{"OID":"520000000000","SHORT_NAME":"贵州省","AREA_LEVEL":-1,"_parentId":null,"state":"closed"}]}

初始化表格函数定义如下:

//查询当前登录人及下级、被当前人员审核 的考核信息
$('#table_khcx').treegrid({
title:'', //标题 考核信息查询
iconCls:'icon-tip', //图标
fit:true,
method:'post', //数据方式
iconCls:'icon-tip', //图标
singleSelect: true, //单选
fitColumns: true, //自动调整各列,用了这个属性,下面各列的宽度值就只是一个比例。
striped: true, //行斑马线
nowrap:false, //true 禁止换行
pagination:true,
pageSize:20,
rownumbers:true, //显示行号
loadMsg:'正在加载,请稍候……', //加载数据的时候显示提示消息
idField:'CODE', //主键字段
queryParams:{}, //查询参数集合
scrollbarSize:18,
idField:'OID',
treeField:'SHORT_NAME',
url:"${ctx}/treegrid/getdata", //数据来源 jiujiayi/pkhxx
columns:[
[
{field:'OID',title:'ID',halign:'center',width:120,sortable:false,hidden:true },
{field:'SHORT_NAME',title:'区域名',halign:'center',width:120,sortable:false},
{field:'AREA_LEVEL',title:'级次',halign:'center',width:120,sortable:false }
]
],
//清除datagrid之前的选择状态
onLoadSuccess:function(){
$('#table_khcx').treegrid('clearSelections');
if($('#table_khcx').treegrid('getRows').length>0){
$('#table_khcx').treegrid('selectRow',0);//默认选中第一行
};
$(this).treegrid('resize'); },
onLoadError:function(){
$.messager.alert("提示",'获取数据失败!','info');
}
})

sql如下:

sql="select OID,SHORT_NAME,AREA_LEVEL, case PARENT_ID when '-1' then null else PARENT_ID end \"_parentId\",'closed' \"state\" "

+ "from Cfg_Basic_Area  where rownum<20 and AREA_LEVEL in ('-1','1')";

最新文章

  1. 让你在PC上调试Web App,UC浏览器发布开发者版
  2. UVM中的class--2
  3. iOS UI基础-17.0 UILable之NSMutableAttributedString
  4. QUnit使用笔记-5简化编写
  5. 20160502-struts2入门--ognl表达式
  6. Java学习----字符串函数
  7. JS常见操作
  8. Scala刮:使用Intellij IDEA写hello world
  9. js判断字符串中是否有数字和字母
  10. JMeter之Http协议接口性能测试
  11. 堡垒机-teleport的安装以及常见问题解决办法
  12. Linux管理日记(一)
  13. DTW动态时间规整
  14. linux command ------ find
  15. python --- 10 *args **kwargs 命名空间 作用域 函数的嵌套
  16. react-native android 和ios 集成 jpush-react-native 激光推送
  17. 【本地服务器】用nginx进行反向代理处理(windows)
  18. Jquery的回调函数的使用
  19. ice服务初探
  20. C语言中FILE是结构体,文件类型的指针

热门文章

  1. MySQL存储引擎(engine:处理表的处理器)
  2. 【paper】KDD15 - Interpreting Advertiser Intent in Sponsored Search
  3. debian 8.1 安装idempiere 2.1 X64 笔记
  4. Android:数据持久化(1/2)文件、SharedPreferences
  5. APP开发浅谈-Fiddler抓包详解
  6. C#连接数据库以及增、删、改、查操作
  7. Visual studio环境中的一些快捷键
  8. chrome扩展程序开发之在目标页面执行自己的JS
  9. bzoj 4530 [Bjoi2014]大融合——LCT维护子树信息
  10. Android JNI访问Java成员