【网络可靠版】Extjs4 Treegrid 使用实例
最近调试EXTJS 4的treegrid实例,看了很多水友的文章,以及官方的demo, 没一个可靠的,全都无法显示出来。像对于我们习惯用C++的coder来说,EXTJS简直就是一群无政府土匪来维护的,官网上连个搜索框都没有,找资料基本靠遍历,还是人工的。
使用treegrid,需要在调用页面的head中加载以下几个文件:
<link rel="stylesheet" type="text/css" href="css/ext-all.css">
<script type="text/javascript" src="ext-all.js"></script>
<script type="text/javascript" src="treegrid.js"></script>
然后在页面的body中写上一个div
<div id="tree-example"></div>
以上官方就这么写的,BUT,蛋疼的是,JS里没有改,不改就没法运行成功。把treegrid.js中的renderto,改成我们的div的ID就行了。
记得把json数据文件和css文件等拷贝到调用目录下。
完成的treegrid.js代码为:
/* This file is part of Ext JS 4 Copyright (c) 2011 Sencha Inc Contact: http://www.sencha.com/contact GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. */
Ext.require([
'Ext.data.*',
'Ext.grid.*',
'Ext.tree.*'
]); Ext.onReady(function() {
//we want to setup a model and store instead of using dataUrl
Ext.define('Task', {
extend: 'Ext.data.Model',
fields: [
{name: 'task', type: 'string'},
{name: 'user', type: 'string'},
{name: 'duration', type: 'string'}
]
});
var store = Ext.create('Ext.data.TreeStore', {
model: 'Task',
proxy: {
type: 'ajax',
//the store will get the content from the .json file
url: 'treegrid.json'
},
folderSort: true
}); //Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
var tree = Ext.create('Ext.tree.Panel', {
title: 'Core Team Projects',
width: 500,
height: 300,
renderTo: 'tree-example',//2B的官方和SV党们,这里竟然是getbody,bo你妹啊。
collapsible: true,
useArrows: true,
rootVisible: false,
store: store,
multiSelect: true,
singleExpand: true,
//the 'columns' property is now 'headers'
columns: [{
xtype: 'treecolumn', //this is so we know which column will show the tree
text: 'Task',
flex: 2,
sortable: true,
dataIndex: 'task'
},{
//we must use the templateheader component so we can use a custom tpl
xtype: 'templatecolumn',
text: 'Duration',
flex: 1,
sortable: true,
dataIndex: 'duration',
align: 'center',
//add in the custom tpl for the rows
tpl: Ext.create('Ext.XTemplate', '{duration:this.formatHours}', {
formatHours: function(v) {
if (v < 1) {
return Math.round(v * 60) + ' mins';
} else if (Math.floor(v) !== v) {
var min = v - Math.floor(v);
return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
} else {
return v + ' hour' + (v === 1 ? '' : 's');
}
}
})
},{
text: 'Assigned To',
flex: 1,
dataIndex: 'user',
sortable: true
}]
});
});
【网络可靠版】Extjs4 Treegrid 使用实例的更多相关文章
- 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误
在visual studio 中添加数据库应用时,报错,提示如下: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL ...
- 在与SQL Server建立连接时出现于网络相关的或特定于实例的错误
客户遇到一个问题,用“服务器名\实例名”远程连接另外一台命名实例的时候连接失败,报“在与SQL Server建立连接时出现于网络相关的或特定于实例的错误,未找到或无法访问服务器.请验证实例名称是否正确 ...
- 与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。
今天同学请教我数据库为什么打不开了,打开SQL Server 2008 的 SQL Server Management Studio,输入sa的密码发现,无法登陆数据库?提示以下错误: "在 ...
- Sql Server Configuration Manager 网络配置为空,没有实例
新用户一天内不准提问...Sql Server Configuration Manager 网络配置为空,没有实例无法设置ip和端口进行连接..
- 酷播迷你flv,mp4网页视频播放器(CuPlayerMini)V2.2版[经典黑]演示实例
酷播迷你flv,mp4网页视频播放器(CuPlayerMini)V2.2版[经典黑]演示实例 http://www.cuplayer.com/cu/FreeDown/
- Sql server在另一台服务器,在Visual Studio 中没问题,IIS中 提示“在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。。。。”
可能问题一: 确切的说是在IIS 7.5中有这问题 就是在visual studio中都用的好好的,但是加载到IIS上的时候竟然报错“ 在与 SQL Server 建立连接时出现与网络相关的或特定于实 ...
- SqlServer 之 用 IP 地址连接数据库报错" 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误 "
问题描述: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (p ...
- VS 连接数据库报错:在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误
VS报错:在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (provider ...
- 在与SQLServer建立连接时出现与网络相关的或特定于实例的错误
标题: 连接到服务器 ------------------------------ 无法连接到 (local). ------------------------------ 其他信息: 在与 SQL ...
随机推荐
- hao947 : Mybatis resultMap配置插入和主键自增返回 : 好947
映射配置文件 好947 <!-- type:映射实体类的数据类型 id:resultMap的唯一标识 --> <resultMap type="person" ...
- Delphi使用StrToDatetime在不同操作系统出现不同的情况(控制面板的时间格式都记录在注册表里,因此也可修改注册表)
Str:= '2010-4-13 06:22:22'; StrToDateTime(Str); 现象:在WinXP, Win2003 都不会报错 但是在Windows7,Windows Serve ...
- jquery中怎么删除<ul>中的整个<li>包括节点
.$('ul li').remove(); .$('ul li').each(function(){ $(this).remove(); }); .$("ul").find(&qu ...
- jquery 设置select的默认值
<select id="sel" > <option value="s1" > aaaa </option> <opt ...
- Java Web Services (2) - 第2章 启动日志分析
ZHAOFLIU-Mac:dev liuzhaofu$ ./start --seed########################################################## ...
- JavaScript面向对象编程(10)高速构建继承关系之对象拷贝
前面的样例我们是通过构造器创建对象.而且希望该对象继承来自另外一个构造器的对象 我们也能够直接面向一个对象来达成继承的目的.使用下属步骤: 1.拷贝一个对象 2.给新对象加入属性 /** * 通过拷贝 ...
- oracle 在操作blob该字段是否会产生很多redo
操作blob该字段是否会产生很多redo,答案是否定的.以下来做一个实验,測试数据库版本号是11.2.0.1.0: --创建一张表做測试之用 create table test_blob ( id ...
- System单元对所有与COM相关的声明就这么多,需要倒背如流
是首先是VM表,但是和COM相关的函数地址都废弃了,这几个VM函数具体放在哪里,还得在研究: { Virtual method table entries } vmtSelfPtr = -; vmtI ...
- ubuntu 64位下安装wps
首先,去官网下载wps.地址:http://community.wps.cn/download/ 然后切换到下载文件夹.运行例如以下命令: $ sudo apt-get install ia32-li ...
- python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overflow
python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overfl ...