【发布时间】:2022-01-24 01:30:56
【问题描述】:
我有一个组合框,我需要在代码中访问商店,以便我可以对其应用过滤器。这是组合的定义。
//ItemGeneralPanel.js
Ext.define('myCompany.view.item.ItemGeneralPanel', {
extend: 'Ext.panel.Panel',
alias: 'widget.myApp.ItemGeneralPanel',
layout: 'vbox',
bodyPadding: 4,
defaults: { width: 800 },
items: [
{
xtype: 'combobox',
fieldLabel: 'Replenishment Source',
displayField: 'name',
valueField: 'id',
queryMode: 'local',
forceSelection: true,
bind: { value: '{item.sourceId}', store: '{replenishmentSourceList}' }
},
]
});
我的 ItemController 里面有这个:
//ItemController.js
stores: [
'item.ItemList',
'item.ReplenishmentSourceList'
],
我的商店是这样的:
//ReplenishmentSourceList.js
Ext.define('myCompany.store.item.ReplenishmentSourceList', {
extend: 'Ext.data.Store',
model: 'myCompany.model.Source',
sorters: 'name'
});
并且模型只有一个字段列表(Source.js):
如何在控制器中引用此组合框,以便获取对其存储的引用,然后对返回的结果应用过滤器。像这样的:
//ItemEditViewController.js
myFunction: function (facilId) {
this.lookup('replenishmentSourceList').getStore().load({
scope: this,
callback: function (records, operation, success) {
if (!success) {
Ext.log({ level: 'error', msg: 'Error loading facility list', dump: operation });
var text = (operation.getError() ? operation.getError().response.responseText : operation.getResponse().responseText);
var msg = Ext.decode(text).message;
Ext.Msg.show({ title: 'Error', msg: 'Error loading Source data.<br>' + msg, buttons: Ext.Msg.OK, icon: Ext.Msg.ERROR });
}
else {
this.lookup('replenishmentSourceList').getStore().setFilters({
property: 'facilityId',
operator: '==',
value: 'facilId'
});
这不起作用,所以我想如果我能得到组合框,我可以做类似的事情: myRefToComboBox.getStore()....
有什么想法吗?
【问题讨论】:
标签: javascript extjs store