首页 > 其他分享 >ExtJS-UI组件-TreePanel

ExtJS-UI组件-TreePanel

时间:2023-01-05 09:35:21浏览次数:56  
标签:leaf text tree Ext UI TreePanel true ExtJS store

ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.html
转载请注明出处:https://www.cnblogs.com/cqpanda/p/16587500.html

更新记录
2023年1月2日 从笔记迁移到博客。

Ext.tree.Panel

实例:基本使用

//Start by defining an Ext.data.TreeStore to load our data into: 
let store = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'treeData.json'
    },
    root: {
        text: 'Countries',
        expanded: true
    }
});

//测试使用的从后端加载的treeData.json内容
[
    {
        "text": "United Kindom",
        "leaf": false
        "children": [
            {
                "text": "Glasgow",
                "leaf": true
            },
            {
                "text": "Edinburgh",
                "leaf": true
            },
            {
                "text": "London",
                "leaf": true
            }
        ]
    },
    {
        "text": "France",
        "leaf": true
    }
]

//Create the Tree Panel and render it to the document's body. 
Ext.create('Ext.tree.Panel', {
    title: 'Countries & Cities',
    width: 500,
    height: 300,
    store: store,
    rootVisible: false,
    renderTo: Ext.getBody(),
    style: 'margin: 50px'
});

实例:排序

在treestore中创建sorters配置项即可

var store = Ext.create('Ext.data.TreeStore', {
    proxy: {
        type: 'ajax',
        url: 'treeData.json'
    },
    root: {
        text: 'Countries',
        expanded: true
    },
    //排序器
    sorters: [
        {
            property: 'text',
            direction: 'ASC' //for descending change to 'DESC'
        }
    ]
});

实例:复杂排序

使用Complex and custom sorting
sorterFn配置项即可

var nameLengthSorter = function(objectOne, objectTwo){
    var objectOneLength = objectOne.get('text').length,
        objectTwoLength= objectTwo.get('text').length;

    if(objectOneLength=== objectTwoLength){
        return 0;
    } else if(objectOne
        Length<objectTwoLength){
        return -1;
    } else {
        return 1;
    }
};

//然后
sorters: [
    {
        sorterFn: nameLengthSorter,
        direction: 'ASC' //for descending change to 'DESC'
    }
]

实例:对多个字段排序

sorters: [
    {
        property: 'text',
        direction: 'ASC'
    },
    {
        property: 'continent',
        direction: 'DESC'
    }
]

实例:后期排序

调用store的sort方法即可

store.sort('text');
//or we can force a direction like so:
store.sort('text', 'DESC');

实例:树之间拖拽节点

Dragging-and-dropping nodes within a tree
enableDrop: true sets the tree to accept drop gestures
enableDrag: false stops the users from dragging nodes within from this TreeView
allowContainerDrop: true allows the user to drop anywhere in the tree's container

//树1:
plugins: {
    ptype: 'treeviewdragdrop'
}
//树2:
plugins: {
    ptype: 'treeviewdragdrop',
    enableDrop: true,
    enableDrag: false,
    allowContainerDrop: true
}

标签:leaf,text,tree,Ext,UI,TreePanel,true,ExtJS,store
From: https://www.cnblogs.com/cqpanda/p/17019703.html

相关文章

  • MAUI Blazor学习4-绘制BootstrapBlazor.Chart图表
    MAUIBlazor学习4-绘制BootstrapBlazor.Chart图表 MAUIBlazor系列目录MAUIBlazor学习1-移动客户端Shell布局-SunnyTrudeau-博客园(cnblogs.com)MAUIBlazor学......
  • 利用GUI制作拼图小游戏
    JFrame表示窗体JMenuBar表示菜单,JMenu表示菜单中的字,JMenuitem表示目录JLabel表示管理文字和图片的文字JFrame,JMenuBar,JLabel称为组件利用空参构造对对象进行初始化:pu......
  • pyautogui + opencv 笔记
    安装pipinstallpyautoguipipinstallopencv-python==3.4.8.291,控制鼠标的移动获取屏幕分辨率>>>importpyautogui>>>宽,高=pyautogui.size()>>>宽,高......
  • How Liquibase Finds Files: Liquibase Search Path
    https://docs.liquibase.com/concepts/changelogs/how-liquibase-finds-files.html Forexample,ifyourreferencedfilepathis project1/db.changelog.xml andy......
  • 针对FreeSWITCH的最佳开源GUI解决方案
    为了获得FreeSWITCH的最大利益,您需要能够正确选择GUI解决方案。看看FreeSWITCH的一些开源GUI解决方案,见证了它们的广泛普及和采用率。FreeSWITCHGUI被广泛地描述为FsG......
  • App ui界面布局基本原则
     页面布局顾名思义就是对页面的文字、图形或表格进行排布、设计。优秀的布局,需要对页面信息进行完整的考虑。即要考虑用户需求、用户行为,也要考虑信息发布者的目的、目......
  • element ui --el-select 嵌套el-tree多选联动、删除联动
    需求:el-select下拉框嵌套el-tree树形组件完成多选、删除、搜索、清空选项等联动功能。特殊需求:(当子节点全部选中时el-select中只展示父节点tag,el-tree组件父子节点全......
  • 如何使用Burp Suite测试WebSocket
    BurpSuite具有测试WebSocket的能力,可以实时拦截和修改WebSocket消息。遗憾的是,Burp缺乏针对WebSockets的Repeater、Scanner或Intruder功能。但在新版BurpSuite中,增加了针对......
  • 渗透工具burpsuite的安装与配置环境变量
    Burpsuite简介Burpsuite是用于攻击web应用程序的集成平台,它可以算是web安全工具里面的瑞士军刀。所有的工具共享一个能处理并显示HTTP消息的可扩展框架,模块之间无缝交换所有......
  • Rpmbuild原码打包成rpm包
    RPM有五种基本的操作功能:安装、卸载、升级、查询和验证。linux软件包分为两大类:(1)二进制类包,包括rpm安装包(一般分为i386和x86等几种)(2)源码类包,源码包和开发包应该归位此类......