最近调试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 使用实例的更多相关文章

  1. 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误

    在visual studio 中添加数据库应用时,报错,提示如下: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL ...

  2. 在与SQL Server建立连接时出现于网络相关的或特定于实例的错误

    客户遇到一个问题,用“服务器名\实例名”远程连接另外一台命名实例的时候连接失败,报“在与SQL Server建立连接时出现于网络相关的或特定于实例的错误,未找到或无法访问服务器.请验证实例名称是否正确 ...

  3. 与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。

    今天同学请教我数据库为什么打不开了,打开SQL Server 2008 的 SQL Server Management Studio,输入sa的密码发现,无法登陆数据库?提示以下错误: "在 ...

  4. Sql Server Configuration Manager 网络配置为空,没有实例

    新用户一天内不准提问...Sql Server Configuration Manager 网络配置为空,没有实例无法设置ip和端口进行连接..

  5. 酷播迷你flv,mp4网页视频播放器(CuPlayerMini)V2.2版[经典黑]演示实例

    酷播迷你flv,mp4网页视频播放器(CuPlayerMini)V2.2版[经典黑]演示实例 http://www.cuplayer.com/cu/FreeDown/

  6. Sql server在另一台服务器,在Visual Studio 中没问题,IIS中 提示“在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。。。。”

    可能问题一: 确切的说是在IIS 7.5中有这问题 就是在visual studio中都用的好好的,但是加载到IIS上的时候竟然报错“ 在与 SQL Server 建立连接时出现与网络相关的或特定于实 ...

  7. SqlServer 之 用 IP 地址连接数据库报错" 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误 "

    问题描述:       在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (p ...

  8. VS 连接数据库报错:在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误

    VS报错:在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误.未找到或无法访问服务器.请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接. (provider ...

  9. 在与SQLServer建立连接时出现与网络相关的或特定于实例的错误

    标题: 连接到服务器 ------------------------------ 无法连接到 (local). ------------------------------ 其他信息: 在与 SQL ...

随机推荐

  1. leetcode第一刷_Sqrt(x)

    这道题乍看下来很easy,实际上要注意的问题许多. 注意看给出来的函数的接口,返回的是int值,也就是计算结果是个近似值.如何求呢?难道是从2開始往上算?直到某个值正好接近x?当然不行,肯定超时了.再 ...

  2. C++ 载入dll

    1.新建一个项目生成dll 首先我们新建一个项目生成一个Dynamic Library(动态链接库) dll 里面非常简单,只有一个add方法.等下我们就要在其他项目里尝试载入这个dll,调用里面的这 ...

  3. 14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量

    14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量 InnoDB 使用bac ...

  4. 腾讯文学动作密集 疑为手Q发力移动阅读铺路

        移动互联网的门票之争并未结束,百度收购91无线,阿里投资新浪微博.UC浏览器,网易推易信.云音乐等等,都是互联网巨头争夺移动互联网门票的最佳案例.不过,上述任何巨头都不可忽视腾讯这个“狠角色” ...

  5. 玩转Windows服务系列——创建Windows服务

    原文:玩转Windows服务系列——创建Windows服务 创建Windows服务的项目 新建项目->C++语言->ATL->ATL项目->服务(EXE) 这样就创建了一个Wi ...

  6. 高逼格UI-ASD(Android Support Design)

    绪 今年的Google IO给我们android开发着带来了三样非常屌非常屌的library: ASD(Android Support Design) APL(Android Percent Layo ...

  7. Transparency Tutorial with C# - Part 2

    Download Compositing Mode demo project - 24 Kb Download Compositing Mode source - 26 Kb Download Com ...

  8. 建立地方Jekyll周边环境

    近期使用github建立一个博客,只是要了解markdown语法,因为markdown后写的不是立即可见.所以,每一个成品都要经过在线调试,在线调试已经上线的文章,每次上线有反复git add, gi ...

  9. linux通过使用mail发送电子邮件

    通过外部方法发送的电子邮件 bin/mail默认为本地sendmail发送电子邮件,求本地的机器必须安装和启动Sendmail服务.配置很麻烦,并且会带来不必要的 资源占用.而通过改动配置文件能够使用 ...

  10. Android -&gt; 怎样避免Handler引起内存泄露

    很多其它内容,可訪问个人博客www.liangfeizc.com 错误代码 假设在Activiy中通过内部类(Runnable)的方式定义了一个变量runnable, final Runnable r ...