国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

Extjs4 Treegrid 使用心得分享(經(jīng)驗(yàn)篇)

2024-05-06 15:48:23
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
最近調(diào)試EXTJS 4的treegrid實(shí)例,看了很多水友的文章,以及官方的demo,沒(méi)一個(gè)可靠的,于是乎自己折騰中...感興趣的朋友可以了解下本文或許對(duì)你有所幫助

最近調(diào)試EXTJS 4的treegrid實(shí)例,看了很多水友的文章,以及官方的demo, 沒(méi)一個(gè)可靠的,全都無(wú)法顯示出來(lái)。像對(duì)于我們習(xí)慣用C++的coder來(lái)說(shuō),EXTJS簡(jiǎn)直就是一群無(wú)政府土匪來(lái)維護(hù)的,官網(wǎng)上連個(gè)搜索框都沒(méi)有,找資料基本靠遍歷,還是人工的。

使用treegrid,需要在調(diào)用頁(yè)面的head中加載以下幾個(gè)文件:

復(fù)制代碼 代碼如下:


<link 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>


然后在頁(yè)面的body中寫上一個(gè)div

復(fù)制代碼 代碼如下:


<div></div>


以上官方就這么寫的,BUT,蛋疼的是,JS里沒(méi)有改,不改就沒(méi)法運(yùn)行成功。把treegrid.js中的renderto,改成我們的div的ID就行了。

記得把json數(shù)據(jù)文件和css文件等拷貝到調(diào)用目錄下。
完成的treegrid.js代碼為:

復(fù)制代碼 代碼如下:


/*
This file is part of Ext JS 4
Copyright (c) 2011 Sencha Inc
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:
If you are unsure which license is appropriate for your use, please contact the sales department at
*/
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
}]
});
});

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 西乌珠穆沁旗| 顺平县| 宝清县| 仁怀市| 团风县| 堆龙德庆县| 游戏| 湖北省| 华宁县| 鸡东县| 绥芬河市| 临汾市| 稷山县| 张家港市| 泰顺县| 凤阳县| 通榆县| 琼结县| 静安区| 孟津县| 唐山市| 名山县| 盐池县| 玉田县| 乐都县| 永和县| 芜湖县| 景宁| 新营市| 赫章县| 德安县| 来宾市| 驻马店市| 原平市| 工布江达县| 恩施市| 恩施市| 永安市| 岢岚县| 无极县| 清水县|