Extjs 組件繼承 模板說明(以GridPanel為例),extjsgridpanel

來源:互聯網
上載者:User

Extjs 組件繼承 模板說明(以GridPanel為例),extjsgridpanel

1. 重寫initComponent()方法,並在該方法在調用父類的initComponent()方法。  如:subclass.superclass.initComponent.call(this);

2. 在initComponent中,出現下面語句,覆蓋父類屬性Ext.apply(this, {    title : "aaa"});

3. 基本模板代碼如下:Ext.ns("my.component");my.component.MyGridPanel = Ext.extend(Ext.GridPanel,{/** * 初始化組件 */initComponent : function(){// 資料倉儲var store = this.store;if(!store){store = this.buildStore(this.baseParams);}// 列模型var cm = this.cm;if(!cm){cm = this.buildCm();}// 複選框.組件屬性使用selModel配置var sm = new Ext.grid.CheckboxSelectionMedol();Ext.apply(this, {// 這裡加上組件的屬性selModel : sm,// 分頁工具條bbar : new Ext.PagingToolbar({}),colModel : new Ext.grid.ColumnModel({// 這裡加上列模型的屬性columns : cm;}),// 對該組件設定監聽器listeners : {"dbclick" : function(){},"rowClick" : function(){},......}});my.component.MyGridPanel.superclass.initComponent.apply(this);},/** * 構建store */buildStore : function(baseParams){Ext.apply(baseParams, {// 分頁條件});return new Ext.data.JsonStore({url : "",idProperty : "", // id屬性值配置totalProperty : "", // autoLoad : boolean,root : "data" // 資料的根,後面的json格式對象數組。fields : [{name : "", mapping : ""},{name : "", mapping : ""},......]});},/** * 構建資料列 */buildCm : function(){return [{name : "", dataIndex : ""},{name : "", dataIndex : ""}];},// 通過選擇模型,擷取選中的記錄。是多條的getSelections : function(){var records = this.getSelectionModel().getSelections();return records;}// 通過選擇模型,擷取選中的記錄。只有一條getSelected : function() {var record = this.getSelectionModel().getSelected();}});







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怎顯示動態產生的組件(grid),怎重新載入取得的json資料?

我寫的答案竟然說有什麼不合法字元。夠鬱悶的,只能用圖片發了,希望管理員看到後處理一下,為什麼我寫的文字發不出去。



 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.