0
我有一個Grid
在Window
。當我點擊該窗口的一行並單擊刪除按鈕時,該行應該從窗口中刪除。 (我想我必須remove it from Store and reload the grid, so the changes will be picked
)從本地網格刪除記錄
我無法獲得點擊事件並從商店中刪除該行。我爲此添加了按鈕,但無法獲取網格記錄並將其從商店中刪除並重新加載。
我的代碼如下;像
Ext.define('MyApp.view.Boy', {
extend: 'Ext.window.Window',
alias: 'widget.boy',
height: 800,
width: 900,
layout: {
type: 'absolute'
},
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'gridpanel',
height: 500,
width: 800,
title: 'My Grid Panel',
store: 'School',
viewConfig: {
},
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'Id',
text: 'id'
},
{
xtype: 'gridcolumn',
dataIndex: 'name',
text: 'name'
}
]
},
{
xtype: 'button',
height: 40,
width: 150,
text: 'Remove',
listeners: {
click: {
fn: me.removebuttonclick,
scope: me
}
}
}
]
});
me.callParent(arguments);
},
removebuttonclick: function(button, e, options) {
console.log('removebuttonclick');
}
});
我得到'類型錯誤:this.grid是undefined'我如何解決這個問題? – 2012-08-01 14:30:05
而不是像你指定的方式使用網格,有沒有辦法使用參數'按鈕'獲得'網格'? – 2012-08-01 14:30:54
對不起,修正了例子中的類型錯誤。呃,如果不使用this.grid是可能的,但你最終會做各種不同的黑客(例如,將點擊的範圍作爲網格傳遞,然後執行this.getSm()等,或者聲明remove函數直接在配置中,或者使用絕對ID,或者走上dom,然後再回落(比聽起來更復雜)) – Alex 2012-08-01 19:41:21