我有TabPanel,其中包含连接到Store的Grid。ExtJS:当其底层存储为空时,从Tabpanel中删除网格
几个事件可能会从商店中删除元素。
我希望当商店是空的,并且可能在我的代码中有一个位置检查此事件时,将从TabPanel中移除网格。
我曾考虑过使用商店监听器,但不幸的是这会导致Ext代码出现异常。 我的假设是发生这种情况是因为渲染是在网格从tabpanel移除之后执行的。
任何想法如何完成这样的任务,而不会搞砸分机非常感谢。 谢谢:)
顺便说一句,这是一个代码摘录:
var myStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({fields: MyRecord}),
listeners:{
'clear': function(store, recs) {
myTabPanel.remove(myGrid);
},
'remove': function(store, rec, idx) {
if (store.getCount() == 0) {
myTabPanel.remove(myGrid);
}
}
}
});
var myGrid = new Ext.grid.GridPanel({
id: "myGrid",
title: "A Grid",
store: myStore,
frame:false,
border:false,
columns: [
{
header: 'Remove',
align:'center',
width: 45,
sortable: false,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
return '<img src="images/remove.png" width="34" height="18"/>';
}
},{
header: 'Some Data',
dataIndex: 'data',
sortable: true
}
],
listeners:{
'cellclick':function(grid, rowIndex, colIndex, e){
var rec = myStore.getAt(rowIndex);
if(colIndex == 0){
myStore.remove(rec);
}
}
}
});
var myTabPanel= new Ext.TabPanel({
activeTab: 0,
items: [ fooPanel, barPanel, myGrid]
});