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: '示例 ...
随机推荐
- 在移动网页网页上点击链接跳转到QQ聊天界面
打开qq聊天窗口的方法 <a href="http://wpa.qq.com/msgrd?v=3&uin=1450612626&site=qq&menu=yes ...
- angular 的进一步深入理解
早上同事问我个问题,angular 的表单验证有没有啥第三方库可以用? 这个问题,我想了下,之前我做的表单验证好像也没用到第三方的库来验证,直接用angular 内置的 directive 就可以搞定 ...
- (转)nio 字符集
字符集 概述 根据 Sun 的文档,一个 Charset 是“十六位 Unicode 字符序列与字节序列之间的一个命名的映射”.实际上,一个 Charset 允许您以尽可能最具可移植性的方式读写字符序 ...
- 使用airdrop进行文件共享
使用airdrop进行文件共享 学习了: https://support.apple.com/zh-cn/HT203106 https://zh.wikihow.com/%E5%9C%A8Mac%E4 ...
- iOS7重磅推新--不断尝试与重新设计的过程
来源:GBin1.com iOS7重磅推新--不断尝试与重新设计的过程 或许你心里已经有了关于iPhone最新操作系统的评价,可能你喜欢它,也可能不喜欢,事实上大多数设计者不喜欢.设计界似乎一致认为I ...
- java中运算符与表达式
运算符是用来完成一个动作的特定语言的语法记号. –赋值运算符 –增减运算符 –算术运算符 –关系运算符 –逻辑运算符 -位运算符 运算符 Java 加 + 减 - 乘 * 除 / 取模 % 1.整数运 ...
- name_search方法的使用
转自:http://blog.csdn.net/littlebo01/article/details/22075573 在many2one类型中,页面下拉时会首先触发name_search方法,参数这 ...
- Android Exception 11(baidumapsdk(15405): Authentication Error errorcode: 102 uid)
08-12 16:06:12.622: E/baidumapsdk(15405): Authentication Error errorcode: 102 uid: null appid -1 msg ...
- vi语法高亮,自动缩进(转)
编辑.vimrc 这样文件在其中加入如下两行就可以了,此法对#号提示符下的操作无效. let &termencoding=&encodingset fileencodings=utf- ...
- Docker背后的内核知识——cgroups资源限制(转)
时间 2015-04-20 21:10:00 InfoQ 原文 http://www.infoq.com/cn/articles/docker-kernel-knowledge-cgroups-re ...