ExtJS TreeGrid的使用方法
假设您是第一次使用ExtJS的TreeGrid的话,我相信总会有一些小麻烦的,以下就来说一说ExtJS中TreeGrid的使用。
本人使用的ExtJS版本号为4.1.1,而且使用了MVC模式。假设不了解ExtJS的MVC模式的话我个认为还是有必要去学学的,
学完后你肯定会喜欢上的。
事实上在ExtJS中并没有TreeGrid这么一个类,这个说法是从EasyUI中借用过来的,ExtJS中的TreeGrid功能已经合在了Ext.tree.Panel中。
TreeGrid显示出来大概是这个样子:
以下是这个样例的源代码:
View:
Ext.define("node.view.NodeListPanel", {
extend : "Ext.tree.Panel",
alias : "widget.nodelistpanel",
title : "节点管理",
columnLines : true,
region: 'center',
root:{
id:'root',
name:'节点管理',
expanded:true
},
columns: [{
xtype : 'treecolumn',
header: '节点名称', dataIndex: 'name', sortable:false,flex:1
}, {
header: '节点编码', dataIndex: 'code',align : 'center',sortable:false,width:150
}, {
header: '节点IP', dataIndex: 'ip', align : 'center',sortable:false,width:150
}, {
header: '端口号', dataIndex: 'port',align : 'center',sortable:false,width:50
}, {
header: '节点描写叙述', dataIndex: 'desc',align : 'center',sortable:false,width:200
}],
loadMask:{
msg : '正在载入数据,请稍等...'
},
store : Ext.create('node.store.NodeStore'),
//store : "NodeStore",
renderTo: Ext.getBody()
});
Store:
Ext.define("node.store.NodeStore", {
extend : 'Ext.data.TreeStore',
//model : 'node.model.Node',//用model传递不了数据
proxy : {
type : 'ajax',
url : 'data/NodeTree.json',
reader : 'json',
autoLoad : true
},
fields : [{
name: 'id',
type: 'string'
}, {
name: 'name',
type: 'string'
}, {
name: 'code',
type: 'string'
}, {
name: 'ip',
type: 'string'
}, {
name: 'port',
type: 'string'
}, {
name: 'desc',
type: 'string'
}]
});
NodeTree.json :
{
"id":"root",
"leaf":false,
"name" : "root",
"children":[{
"id":"1",
"leaf":true,
"name" : "公安",
"code" : 452363214,
"ip" : "192.168.0.203",
"port" : 8080,
"desc" : "公安节点"
}, {
"id":"4",
"leaf":true,
"name" : "法院",
"code" : 452364587,
"ip" : "192.168.0.204",
"port" : null,
"desc" : "法院节点"
}, {
"id":"9",
"leaf":true,
"name" : "检查院",
"code" : 452312365,
"ip" : "192.168.0.205",
"port" : null,
"desc" : "检查院节点"
}, {
"id":"10",
"leaf":false,
"name" : "纪检委",
"code" : 45234596,
"ip" : "192.168.0.235",
"port" : null,
"desc" : "纪检委节点",
"expanded":true,
"children":[{
"id":"2",
"leaf":true,
"name" : "測试节点",
"code" : 45239658,
"ip" : "192.168.0.255",
"port" : null,
"desc" : "測试节点"
}]
}]
}
Controller:
Ext.define('node.controller.NodeController', {
extend:'Ext.app.Controller',
init:function(){
this.control({
});
},
views: [
'NodeListPanel'
],
stores: [
//"NodeStore"
],
models: [
//"Node"
]
});
app.js :
Ext.onReady(function(){
Ext.Loader.setConfig({
enabled : true
});
Ext.application({
name : "node",
appFolder : ".",
launch : function() {
Ext.create("Ext.container.Viewport", {
layout : "border",
items : [{
xtype : "nodelistpanel"
}]
});
},
controllers : [
'NodeController'
]
});
});
在这里有两个非常奇怪的地方:
1. NodeListPanel指定Store时,不能直接配置成store:"NodeStore"让其动态载入,而要直接创建出来,所以在Controller中不指定NodeStore也是能够的
2. NodeStore不能直接指定Model。而应该配置其fields属性取代,由于配置Model对TreeStore来说根本不起作用
以上两点至于为什么会这样,本人也没有去深究,望高人直接指点。
另一个须要注意的地方就是一定要为TreePanel配置root属性,否则无法显示树形
ExtJS TreeGrid的使用方法的更多相关文章
- Extjs 选择元素涉及方法总结
本文主要是解释Extjs在使用过程中使用的相关选择方法: 1.首先解释第一组概念: Ext.get(String/HTMLElement/Ext.Element el) Ext.getCmp(Stri ...
- [ExtJS5学习笔记]第三十五节 sencha extjs 5 组件查询方法总结
一个UI前台组件肯定会比较多,我们通常习惯性的使用ID来获取需要操作的组件,但是这种方法是extjs推荐的么?有没有extjs推荐使用的获取组件的方法呢? 目录 目录 extjs的查询组件的API 查 ...
- [转]Extjs中的迭代方法
原文地址:http://www.veryhuo.com/a/view/36701.html EXTJS 有很多的迭代方法,例如,你也许已知道的Ext.each,但还有另外一些不为人知且很有用的方法.首 ...
- [ExtJS5学习笔记]第三十五条 sencha extjs 5 组件查询方法
一UI前部组件势必更加,我们通常习惯性使用ID获取部件操作的需要.但是,这种方法是extjs推荐么?你有吗extjs利用它来获取组件的推荐方法? 夹 文件夹 extjs的查询组件的API 查询实例 主 ...
- Extjs 一些配置以及方法
1.例如想要实现以下功能,本来model中只有用户的firstname和lastname,但是在grid中展示还需要展示用户姓名,或者只展示用户姓名
- ExtJs radiogroup form.loadRecord方法无法赋值正确解决办法
一.radiogroup的name和radio的name一致,inputValue为整形 { xtype: 'radiogroup', fieldLabel: '是否有效', name: 'statu ...
- Extjs 分页传参方法
第一种(常用): var proxy = new Ext.data.HttpProxy({url : url}) var store = new Ext.data.Store({ pruneModif ...
- EasyUI treegrid 获取编辑状态中某字段的值 [getEditor方法获取不到editor]
如题,在treegrid里,按照api里getEditor方法的说明, getEditoroptionsGet the specified editor, the options contains t ...
- ExtJS 中类的选项 - config
首先看一个例子,我们在ExtJS中定义一个Window对象,代码如下: var win = Ext.create("Ext.window.Window", { title: '示例 ...
随机推荐
- Mysql数据库配置文件my.cnf详解
basedir = path 使用给定目录作为根目录(安装目录). character-sets-dir = path 给出存放着字符集的目录. datadir = path 从给定目录读取数据库文件 ...
- [OpenCV]实验1.1:图像加载、显示
实验要求:利用图像库的功能,实现从文件加载图像,并在窗口中进行显示的功能:利用常见的图像文件格式(.jpg;.png;.bmp; .gif)进行测试 实验原理:图片读取到程序中是以Mat结构存储的,在 ...
- 关于windows下自带的forfile批量删除文件bat命令
最近在开发的过程中,为了节省资源,需要用到windows下批量删除文件的批处理命令,也就是bat 主要内容: forfiles /p "E:\pictures" /m * /d - ...
- tomcat通过虚拟路径访问外部静态资源
转载:http://blog.csdn.net/yuancenyi/article/details/53414397 在项目开发中,单个工程中,为了以后软件版本升级的方便,经常将网站运行中某些上传的静 ...
- 切换样式.toggleClass()
切换样式.toggleClass() 在做某些效果的时候,可能会针对同一节点的某一个样式不断的切换,也就是addClass与removeClass的互斥切换,比如隔行换色效果 jQuery提供一个to ...
- ppm图像格式
http://blog.csdn.net/r91987/article/details/5435328 PPM文件格式分三种: 1. PPM灰度文件 文件头由3行文本组成,可由fgets读出 ...
- Python/MOOC /翻Wall和互联网编程的那些事
Python MOOC 翻Wall和互联网编程的那些事 声明: 1)本报告由博客园bitpeach撰写,版权所有,免费转载,请注明出处,并请勿作商业用途. 2)若本文档内有侵权文字或图片等内容,请联系 ...
- RelativeLayout与LinearLayout的比较
转自:http://blog.csdn.net/onepiece2/article/details/26396287 RelativeLayout 是相对布局在页面上相对于页面坐标进行布局设置.比如可 ...
- CodeForces 390E Inna and Large Sweet Matrix(树状数组改段求段)
树状数组仅仅能实现线段树区间改动和区间查询的功能,能够取代不须要lazy tag的线段树.且代码量和常数较小 首先定义一个数组 int c[N]; 并清空 memset(c, 0, sizeof c) ...
- 【FinancialKnowledge】拨备
一句话: 银行拨备就是银行贷款损失减值准备的俗称,其相当于为承担风险和损失的金融资产计提的准备金 通俗易懂的解释见:https://wallstreetcn.com/articles/3307725