树型表格是一种树和可编辑表格的结合体,使得数据的浏览和管理更为人性化。树型表格尤其在制作项目进度表、甘特图方面有着非常广泛的应用。
准备工作
在sample项目的src目录下新建ViewModel,命名treeGrid。新建关联表PROJECT的AutoSqlDataset,命名datasetProject并设置其中label的属性值。
name | label | dataType |
---|---|---|
id |
| int |
task_name | 任务 | string |
parent_id |
| int |
start_time | 开始时间 | date |
end_time | 结束时间 | date |
owner | 负责人 | string |
checker | 检查人 | string |
progress | 完成进度 | int |
表14-01
图14-60
datasetProject新建完成后,需要配置其MatchRules匹配规则。步骤:【datasetProject】—》【Modify...】。
图14-61
设置PARENT_ID为查询参数。
图14-62
完成datasetProject的MatchRules配置之后,在datasetProject节点下新建Parameter对象。步骤:【datasetProject】—>【Parameters】—>【Insert】—>【Parameter】。
图14-63
配置新建的Parameter对象参数名为PARENT_ID,选择数据类型dataType值为string,参数值为$null。
图14-64
新建树型表格控件
在Controls节点下新建树型表格控件TreeGrid。步骤:【Controls】—>【Insert】—>【Tree】—>【TreeGrid】。
图14-65
在【Set Properties】窗口,设置TreeGrid绑定datasetProject,选择【Auto create columns】为√。
图14-66
点击【Finish】完成TreeGrid的创建。
图14-69
配置树型表格中的属性
在treegridProject中,设置recursiveKeyFields属性值为ID,recursiveKeyParameters属性值为PARENT_ID,treeColumn属性值为TASK_NAME。
图14-70
保存全部修改,新建treeGrid相关的JSP页面tree_grid.jsp,通过【Browse】查看页面效果。
图14-71
调整树型表格控件
完成树型表格的示例之后,并非大功告成,我们还需要做些调整的工作,确保最终展现的效果更符合实际需求。
在treegridProject控件中删除ID、PARENT_ID两列,并设置treegridProject的width和height属性值均为100%,并且设置fixColumn的属性值为1。
图14-72
开发步骤
树型表格控件兼具数据树和数据表格的特性,其中树状的节点是采用绑定Dataset并利用递归实现的。树型表格的recursiveKeyFields和recursiveKeyParameters属性的概念和用法与DataTree中的Recursive TreeLevel并无区别。
|
|
|
|
|
|
|
|
Attachments:















