我在EXT庫初學者,我試圖延長網格面板,並從我的新類記錄一個引用其商店:this.store未定義
Ext.define('App.ui.CategoryGridPanel', {
extend : 'Ext.grid.Panel',
initComponent : function() {
var storeToUse = this.store;
if (storeToUse == null) {
storeToUse = Ext.data.StoreManager.lookup(StoreIDs.CategoryStore);
}
this.categoryRowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit : 2,
store : storeToUse,
listeners : {
edit : function(editor, e) {
this.store.sync();
}
}
});
Ext.apply(this, {
store : storeToUse,
height : 400,
width : 300,
plugins : [ this.categoryRowEditing ],
columns : [ {
header : 'Description',
dataIndex : 'description',
flex : 1,
sortable : true,
editor : 'textfield'
} ],
tbar : [ {
xtype : 'button',
text : 'New',
handler : this.insertNewCategory
} ]
});
this.callParent(arguments);
},
/**
* Add new Category to grid.
*/
insertNewCategory : function() {
var category = Ext.create(ModelNames.Category, {
description : ''
});
this.store.insert(0, category);
this.categoryRowEditing.startEdit(0, 0);
}
});
方法inserNewCategory總是拋出放一些提醒我發現this.store返回null後不能打電話的不確定 插入。 我檢查了分機示例代碼,但我沒有做任何不同的事情。
請幫助:(
非常感謝兩件事,回答我的問題,並給我提示在哪裏尋找。 – 2012-04-22 11:53:18
如果答案適用於您 - 請將其標記爲「已回答」。 – sha 2012-04-22 11:54:33