導航:首頁 > 編程語言 > extjs2實例

extjs2實例

發布時間:2025-05-26 06:09:44

① 如何讓Extjs4.1中的treegrid和treestore實現分頁

Extjs treeGrid分頁實例,項目中用到,拿出來跟大家分享一下,主要是通過兩個store實現。

[javascript] view plain
ProTreeGrid = Ext.extend(Ext.tree.Panel, {
_baseParam : {
process : '項目立項',
isShow : 'true',
start : 1
},
constructor : function(_config) {
if (_config == null)
_config = {};
Ext.apply(this, _config);

this.store1 = Ext.create('Ext.data.JsonStore', {
autoLoad : true,
pageSize : basicConstant.LIMIT,
proxy : {
type : 'ajax',
url : "xmgl/pro-info-manage!page.action",
extraParams : this._baseParam,
reader : {
type : 'json',
root : 'rows',
totalProperty : "totalCount"
}
},
model : 'ProInfo'
});

this.store = Ext.create('Ext.data.TreeStore', {
model : 'ProInfo',
proxy : {
type : 'ajax',
url : 'xmgl/pro-info-manage.action'
},
folderSort : true,
listeners : {
'beforeload' : {
fn : function(_s, _op, _e) {
this._baseParam.limit = basicConstant.LIMIT;
_s.proxy.extraParams = this._baseParam;
},
scope : this
}
}
});

this['selModel'] = Ext.create('Ext.selection.TreeModel', {
mode : 'SINGLE',
listeners : {
'selectionchange' : {
fn : this.selectionChangeHandler,
scope : this
}
}
});
this['columns'] = [ {
xtype : 'treecolumn',
text : '項目性質',
flex : 1,
sortable : true,
dataIndex : 'proClass'
}, {
text : '項目名稱',
flex : 2.5,
dataIndex : 'proName',
sortable : true
}, {
text : '流程狀態',
flex : .75,
dataIndex : 'process',
sortable : true
}, {
text : '項目時間',
xtype : 'datecolumn',
format : 'Y-m-d',
dataIndex : 'crTime',
sortable : true,
flex : .85
}, {
text : '項目編號',
flex : 1,
dataIndex : 'proNo',
sortable : true
}, {
text : '項目單位',
flex : 1,
dataIndex : 'unit',
sortable : true
}, {
text : '優先順序',
flex : .6,
dataIndex : 'priority',
sortable : true
}, {
text : '項目類型',
flex : .75,
dataIndex : 'proType',
sortable : true
}, {
text : '項目內容',
flex : 2,
dataIndex : 'proContent',
sortable : true
}, {
text : '附件數',
flex : .6,
dataIndex : 'fileCount',
sortable : true
} ]
ProTreeGrid.superclass.constructor.call(this, {
useArrows : true,
height : this._height,
width : this._width,
autoScroll : true,
rootVisible : false,
dockedItems : [ {
_treeGrid : this,
xtype : 'pagingtoolbar',
id : 'PROTREEGRID_PAGEBAR',
store : this.store1,
dock : 'bottom',
displayInfo : true,
listeners : {
change : function(obj, pdata, options) {
if(this._treeGrid._baseParam.start==pdata.currentPage)
return;
this._treeGrid._baseParam.start = pdata.fromRecord;
this._treeGrid._baseParam.limit = basicConstant.LIMIT;
this._treeGrid.store.load( {
params : this._treeGrid._baseParam
});
}
}
} ],
viewConfig : {
stripeRows : true,
enableTextSelection : true,
getRowClass : function(record) {
if (record.get("proClass") == '收入項目') {
return 'srcss';
} else if (record.get("proClass") == '支出項目') {
return 'zccss';
}
}
},
tbar : new Ext.toolbar.Toolbar( {
id : 'TBAR_PROTREEGRID',
items : [ new ProClassQueryCombo( {
width : 140,
labelWidth : 60
}), '-', '項目名稱:', {
xtype : 'textfield',
width : 70
}, '無分項總體項目顯示:', {
xtype : 'checkbox',
checked : true,
width : 70
}, {
text : "查詢",
icon : 'images/icons/search.gif',
handler : this.onSearch,
scope : this
}, {
text : "重置",
icon : 'images/icons/del.gif',
handler : this.onReset,
scope : this
}, {
text : "高級查詢",
icon : 'images/icons/search.gif',
handler : this.onAdvSearch,
scope : this
} ]
})
});
},
selectionChangeHandler : function() {
},
reLoadData : function() {
this.store.load( {
params : this._baseParam
});
this.store1.load( {
params : this._baseParam
});
},
onSearch : function() {
var _param = {};
var _tbar = Ext.getCmp('TBAR_PROTREEGRID');
_param.process = _tbar.items.items[0].value;
_param.proClass = _tbar.items.items[2].value;
_param.proName = _tbar.items.items[5].value;
_param.isShow = _tbar.items.items[7].value;
// this.store1.load(1);
this._baseParam = _param
this.reLoadData();
},
onReset : function() {
var _tbar = Ext.getCmp('TBAR_PROTREEGRID');
_tbar.items.items[0].setValue('項目立項');
_tbar.items.items[2].setValue('');
_tbar.items.items[5].setValue('');
this._baseParam = {
process : '項目立項',
isShow : 'false'
};
},
onAdvSearch : function() {
new ProQueryWin( {
_grid : this,
_process : '項目立項'
}).show();
}

});

② extjs的panel組件怎麼使用

//html代碼
<div id="container">
</div>

//js代碼
var p = new Ext.Panel({
title: 'My Panel',//標題
collapsible:true,//右上角上的那個收縮按鈕,設為false則不顯示
renderTo: 'container',//這個panel顯示在html中id為container的層中
width:400,
height:200,
html: "<p>我是內容,我包含的html可以被執行!</p>"//panel主體中的內容,可以執行html代碼
});

因為panel組件的子類組件包括TabPanel,GridPanel,FormPanel,TreePanel組件,所以非常有必要介紹Panel組件的配置參數和相關的屬性、方法。

//配置參數(只列舉部分常用參數)
1.autoLoad:有效的url字元串,把那個url中的body中的數據載入顯示,但是可能沒有樣式和js控制,只是html數據
2.autoScroll:設為true則內容溢出的時候產生滾動條,默認為false
3.autoShow:設為true顯示設為"x-hidden"的元素,很有必要,默認為false

4.bbar:底部條,顯示在主體內,//代碼:bbar:[{text:'底部工具欄bottomToolbar'}],
5.tbar:頂部條,顯示在主體內,//代碼:tbar:[{text:'頂部工具欄topToolbar'}],
6.buttons:按鈕集合,自動添加到footer中(footer參數,顯示在主體外)//代碼:buttons:[{text:"按鈕位於footer"}]
7.buttonAlign:footer中按鈕的位置,枚舉值為:"left","right","center",默認為right

8.collapsible:設為true,顯示右上角的收縮按鈕,默認為false
9.draggable:true則可拖動,但需要你提供操作過程,默認為false

10.html:主體的內容
11.id:id值,通過id可以找到這個組件,建議一般加上這個id值
12.width:寬度
13.height:高度
13.title:標題

14.titleCollapse:設為true,則點擊標題欄的任何地方都能收縮,默認為false.

15.applyTo:(id)呈現在哪個html元素裡面
16.contentEl:(id)呈現哪個html元素裡面,把el內的內容呈現
17.renderTo:(id)呈現在哪個html元素裡面
//關於這三個參數的區別(個人認為:applyTo和RenderTo強調to到html元素中,contentEl則是html元素到ext組件中去):
英文如下(本人英語poor,不敢亂翻譯):
contentEl - This config option is used to take existing content and place it in the body of a new panel. It is not going to be the actual panel itself. (It will actually the innerHTML of the el and use it for the body). You should add either the x-hidden or the x-hide-display CSS class to prevent a brief flicker of the content before it is rendered to the panel.
applyTo - This config option allows you to use pre-defined markup to create an entire Panel. By entire, I mean you can include the header, tbar, body, footer, etc. These elements must be in the correct order/hierarchy. Any components which are not found and need to be created will be autogenerated.
renderTo - This config option allows you to render a Panel as its created. This would be the same as saying myPanel.render(ELEMENT_TO_RENDER_TO);
哪位大人幫忙翻譯下...
考慮到入門,方法事件會在以後的文章中以實例穿插。
1.可拖動的panel實例
下面我們做個可拖動panel例子來熟悉下panel這個最基本的組件.

//html代碼
..無..

//下面創建一個允許拖動的panel,但是拖動的結果不能保存
var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),//x,y,renderTo:Ext.getBody()初始化panel的位置
floating: true,//true
frame: true,//圓角邊框
width: 400,
height: 200,
draggable:true
}).show();//在這里也可以不show()
但是還不能拖到其他的地方,我們需要改寫draggable:

draggable: {
insertProxy: false,//拖動時不虛線顯示原始位置

onDrag : function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);//獲取拖動時panel的坐標
},
endDrag :

function(e){
this.panel.setPosition(this.x, this.y);//移動到最終位置
}
}
實現了可保存的拖動

拖動的時候陰影還在原位置,我們再在draggable中的onDrag事件中添加代碼:

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
//shadow的realign方法的四個參數,改變shadow的位置大小屬性
最後這個可拖動的panel的代碼為:

var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),
floating: true,
frame: true,
width: 400,
height: 200,
draggable: {
insertProxy: false,
onDrag :

function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
},
endDrag : function(e){
this.panel.setPosition(this.x, this.y);
}
}
})
//效果圖片我就不貼出來了
2.帶頂部,底部,腳部工具欄的panel

var p=new Ext.Panel({
id:"panel1",
title:"標題",
collapsible:true,
renderTo:"container",
closable:true,
width:400,
height:300,
tbar:[{text:"按鈕1"},{text:"按鈕2"}], //頂部工具欄
bbar:[{text:"按鈕1"},{text:"按鈕2"}], //底部工具欄
html:"內容",
buttons:[{text:"按鈕1"},{text:"按鈕2"}] //footer部工具欄
});

我們已經在各種工具欄上添加了按鈕,但是卻沒有激發事件,下面我們來添加按鈕事件代碼:

tbar:[{text:"按鈕1",handler:function(){Ext.MessageBox.alert("我是按鈕1","我是通過按鈕1激發出來的彈出框!")}},{text:"按鈕2"}],
//改寫tbar,添加handler句柄,點擊頂部工具欄上按鈕1,彈出提示框,效果圖大家想像下,就不貼出來了
當然,一般情況下,我們只要一個工具欄,這里只是為了演示!
3.panel工具欄

//添加下面的代碼到panel配置參數中
tools:[{id:"save"},{id:"help"},{id:"up"},{id:"close",handler:function(){Ext.MessageBox.alert("工具欄按鈕","工具欄上的關閉按鈕時間被激發了")}}],
//id控制按鈕,handler控制相應的事件
//id的枚舉值為:
toggle (collapsable為true時的默認值)
close
minimize
maximize
restore
gear
pin
unpin
right
left
up
down
refresh
minus
plus
help
search
save
print

③ easyui和extjs哪個好

作為ExtJs和EasyUI都用得很熟練的一個老資格程序員,我發表一下我的看法。

首先兩個框架的組件都很豐富,商業應用都要收費。ExtJS的動態性和擴展性更好,從使用效果看,easyui的組件相對體驗更好一點。

ExtJS

優點:1.完全開源,我說的開源的意思並不是說不收費。

2.我非常贊賞它的架構設計,完全的面向對象的組件化設計。所有的組件都是從一些基礎的組件派生出來的,並且提供了overide,extend等擴展方式,可以說能夠任意擴展。可能一些半桶水的人覺得ExtJS很難用,那是因為他們只懂皮毛。

3.ExtJS的文檔和實例做得比EasyUI要好得多,基礎比較好的開發人員只用看官方的文檔、demo、適當參考源碼就能夠完成任何工作,遇到問題完全不用去網路或論壇問其他人。

4.可以完全動態開發,代碼都寫在JS文件里,不像ExtJS那樣非得在頁面放一個DOM元素。所以可以自己定製組件在任意頁面引用,復用性好。

缺點:1.可能太多人用,造成審美疲勞,反正我看膩了它的界面,自己定製界面主題有太難。

2.可能因為它太龐大,不像easyUI那樣基於頁面已有的HTML

DOM渲染,所以一般人覺得比較難(但是話有說會來,如果使用者的水平高的話,這其實也是也是它的優點。因為你要是在同一個界面點擊不同按鈕要動態顯示各種各樣不同的window、form等等的話,只要把這些JS引用到當前頁面就可以吧,見上述優點4)。

easyui

優點:

1.在頁面的DOM元素加一些屬性然後加幾行JS就可以動態構造出相應的組件。開發方式相對ExtJS直觀和簡潔一些。

2.組件相對體驗更好一點,界面好像跟干凈簡潔。

缺點:1.半開源,對於一個高手來說看不到源代碼是很痛苦的,事,因為他們總有這樣那樣的擴展需求。

2.一定要在頁面上放置相應的DOM元素才能渲染(如果不對dom元素設置隱藏的話,在頁面沒有渲染過程中會顯示一堆亂七八糟的東西)所以無法自己定製組件在其他頁面引用,要復用的話得搬磚一樣把JS和DOM都復制過來,遇到非常復雜的頁面那是相當雜亂和痛苦的。

④ extjs中在GridPanel上添加一個搜索框 (文本框+按鈕)怎麼實現啊。。

直接配置到工具條tbar里就行了:
var grid = new Ext.grid.GridPanel({
id: "grid1",
title: "GridPanel實例",
renderTo: "div1",
width: 500,
height: 300,
frame: true,
tbar: [{xtype:'label',text:'請輸入關鍵詞:'},{xtype:'textfield',id:'KeyWord'},{text:'搜索',handler:function(){alert("搜索");}}
],
。。。。。//其它配置項
});

⑤ extjs的作用

extjs主要功能:
1、網格
大型數據頁面的無限/緩沖滾動功能得到很大改進。同時,對於網格的「鎖定」功能,新增了鎖定和未鎖定兩種狀態。
2、布局
在布局上,通過避免瀏覽器迴流來加快訪問速度(瀏覽器迴流,指瀏覽器為了重新渲染部分或全部的文檔而重新計算文檔中元素的位置和幾何結構的過程)。同時,新增了「邊界」布局方式。收縮包圍的寬度問題,以前是用特定組件來處理,現在改為用核心組件來處理。
3、核心組件
XTemplates和方法重寫功能得到顯著改善。Ext.override現在開始支持重寫實例方法,並且,可以通過使用標準的callParent函數來訪問被重寫的方法。
此外,4.1版本開始支持通過使用函數名來實現事件監聽器。

⑥ 有沒有ext gwt、ExtJS相關介紹、教程之類的書(出版的)介紹一下

最近也在用gxt(也就是ext gwt)做項目,但gxt在國內明顯沒有人氣,中文的教程一本回沒有,英文的有一本《答Developing with Ext GWT Enterprise RIA Development》,可以在淘寶上買到。主要還是靠論壇,GXT的技術支持(花錢買的),以及gxt提供的demo進行學習和開發的。
說實話我還是很喜歡gxt的,畢竟我不是很精通javascript。GXT最大的問題還是在於多瀏覽器的兼容性問題,特別是IE。這也可能不是GXT的問題而是GWT的問題。

ext js 的話除了樓上的推薦一本《JavaScript凌厲開發—Ext JS 3詳解與實踐》。如果你要買《深入淺出ext》,一定要買第二版,引入了Ext JS最新版本3.2的新特性。第一版是沒有的。如果你有心更深入,可以讀這個《EXTJS 源碼分析與開發實例寶典》,分析ext js源代碼,讀懂了絕對牛人。

關於gxt有什麼問題可以一起交流下,幹了半年多還是略有心得的。

閱讀全文

與extjs2實例相關的資料

熱點內容
doc文件下載軟體 瀏覽:20
惠普電腦優盤裝系統教程 瀏覽:14
描述文件信任會中毒嗎 瀏覽:79
tbf資料庫怎麼開 瀏覽:436
網路互動的形式 瀏覽:546
怎樣打開qq設置默認瀏覽器下載文件夾 瀏覽:996
編程如何使計算結果保留整數 瀏覽:278
19歲學編程應該從哪裡入門 瀏覽:82
單文件模型是什麼 瀏覽:409
我的世界有附魔台的版本下載 瀏覽:597
蘋果6s攝像頭會磨損嗎 瀏覽:376
win10如何無線網路連接列印機 瀏覽:982
如何用編程貓做網路游戲 瀏覽:69
有哪些福利彩票網站 瀏覽:168
什麼樣的紅頭文件有效 瀏覽:312
咋么做微信相冊 瀏覽:669
mac系統刪除win10系統文件恢復 瀏覽:91
加域失敗怎麼改密碼錯誤 瀏覽:156
javasession保存對象 瀏覽:308
福州哪裡有學習數控編程的 瀏覽:40

友情鏈接