[英]ExtJS 4.2 - Refresh grid with current variable store
我在面板窗口上有一個加載某個商店的網格面板:
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'
}]
}
在我的控制器上,我處理一個函數,在request
之前將custStore
放到它和其他參數。
click: function() {
oController.addPlayerToTag(newPlayer, tagId, custStore);
}
問題 :我該如何重裝custStore
在gridpanel
我是一個成功的回調后? 我嘗試使用custStore.load()
但沒有任何反應。
如果我理解正確,您將從服務器返回一個新的客戶數組,並需要使用該數組刷新網格。 在這種情況下,我認為你需要在custStore上調用setData ,傳入新的客戶數組。 不確定4.2是否有這種方法。 如果沒有,請嘗試設置custStore.data屬性。
如果僅此一項不起作用,請嘗試在網格上調用reconfigure ,並傳入custStore。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.