我在面板窗口上有一个网格面板,它加载某个商店:
xtype: 'gridpanel',
store: custStore,
viewConfig: {
loadMask: false,
enableTextSelection: true
},
hideHeaders: false,
bodyBorder: true,
id: 'playerslist-grid-id',
itemId: 'playerslist-grid-id',
viewConfig: {
deferEmptyText: false,
emptyText: 'No records yet'
},
columns: [{
text: 'Customer',
dataIndex: 'username',
flex: 1
}, {
header: '',
xtype: 'actioncolumn',
itemId: 'remove-player-btn',
width: 50,
sortable: false,
resizable: false,
menuDisabled: true,
hidden: bHide,
items: [{
icon: 'resources/img/x.png',
tooltip: 'Remove Player',
scope: oMe
}],
editor: {
xtype: 'text',
name: 'deleteRow'
}
}]
custStore
变量的处理方式如下。
var oMe = this;
oController = EcommBackoffice.Global.app_var.getController('CustomerTagsController'),
cStore = oController.getCustomerListStore(),
cDetails = cStore.first(),
customers = [];
customers = cDetails.get('customers');
var custStore = Ext.create('Ext.data.ArrayStore', {
model: 'CustomerList',
data: customers
});
我需要把它放在数组存储中,因为数据对象是这样嵌套的:
{
id: 1,
name: 'test',
description: 'test',
customers: [{
id: 001,
username: 'bob'
}, {
id: 001,
username: 'terese'
}, {
id: 001,
username: 'dab'
}, {
id: 001,
username: 'bba'
}, {
id: 001,
username: 'hello'
}]
}
在我的控制器上,我处理一个函数,将custStore
和其他参数放在request
之前。
click: function() {
oController.addPlayerToTag(newPlayer, tagId, custStore);
}
问题:成功回调后,如何在我所在的gridpanel
上重新加载custStore
?我试着使用custStore.load()
,但什么也没发生。
如果我理解正确,您将从服务器返回一个新的客户阵列,并需要使用该阵列刷新网格。在这种情况下,我认为您需要调用custStore上的setData,传入新的客户数组。不确定4.2是否有这种方法。如果没有,请尝试设置custStore.data属性。
如果仅此操作不起作用,请尝试在网格上调用reconfigure,并传入custStore。