Ext4.2学习之表格和树形的结合

在ext中可以通过扩展使用treecolumn插件的方式实现表格与树形结合的效果。
在这里插入图片描述
加载的11-01.txt数据如下

[{
    task:'EXT程序开发',
    duration:'12个月',
    user:'',
    cls:'master-task',
    iconCls:'task-folder',
    children:[{
        task:'第一章介绍EXT',
        duration:'1个月',
        user:'Lingo',
        leaf:true,
        iconCls:'task'
    },{
        task:'第二章GRID',
        duration:'2个月',
        user:'ForgetDavid',
        leaf:true,
        iconCls:'task'
    },{
        task:'第十一章常用工具',
        duration:'9个月',
        user:'Lingo',
        leaf:true,
        iconCls:'task'
    }]
},{
    task:'协同办公OA',
    duration:'3个月',
    user:'',
    cls:'master-task',
    iconCls:'task-folder',
    children:[{
        task:'平台搭建',
        duration:'1个月',
        user:'Lingo',
        leaf:true,
        iconCls:'task'
    },{
        task:'系统设计',
        duration:'1个月',
        user:'Lingo',
        leaf:true,
        iconCls:'task'
    },{
        task:'编码实现',
        duration:'1个月',
        user:'Lingo',
        leaf:true,
        iconCls:'task'
    }]
}]

效果如下所示,这里使用了cls和iconcls来定义树形节点的样式和图标,使用children为树杈节点设置子节点,使用leaf定义叶子节点
在这里插入图片描述
对应源码

<!DOCTYPE html>
<html>
<head>
    <title>Hello World</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="ext-4/resources/css/ext-all.css"/>
    <script type="text/javascript" src="ext-4/ext-all.js"></script>
    <script type="text/javascript" src="ext-4/locale/ext-lang-zh_CN.js"></script>
    <style type="text/css">
        .task {
            background-image: url(icons/fam/cog.gif) !important;
        }
        .task-folder {
            background-image: url(icons/fam/folder_go.gif) !important;
        }
    </style>
    <script type="text/javascript">
        Ext.Loader.setConfig({
            enabled: true
        });

        // Ext.require([
        //     'Ext.data.*',
        //     'Ext.grid.*',
        //     'Ext.tree.*',
        //     'Ext.ux.CheckColumn'
        // ]);


        Ext.onReady(function(){
            Ext.define('Task', {
                extend: 'Ext.data.Model',
                fields: [
                    {name: 'task',     type: 'string'},
                    {name: 'user',     type: 'string'},
                    {name: 'duration', type: 'string'}
                ]
            });

            var tree = new Ext.tree.TreePanel({
                width: 550,
                height: 300,
                rootVisible:false,
                autoScroll:true,
                title: '示例',
                renderTo: 'tree',
                collapsible: true,
                useArrows: true,

                columns:[{
                    xtype: 'treecolumn',
                    header:'任务',
                    width:330,
                    dataIndex:'task'
                },{
                    xtype: 'treecolumn',
                    header:'持续时间',
                    width:100,
                    dataIndex:'duration'
                },{
                    xtype: 'treecolumn',
                    header:'负责人',
                    width:100,
                    dataIndex:'user'
                }],
                store: new Ext.data.TreeStore({
                    model: Task,
                    proxy: {
                        type: 'ajax',
                        url: '11-01.txt'
                    },
                    root: {
                        text: '我是根'
                    }
                })
            });

        });
    </script>
</head>
<body>
<div id="tree" style="height:300px;"></div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lang20150928

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值