您好,我有一个问题,存储动态值到extraParams
上的extjs..
我的情况是我可以从我的组件中获得值,当我在这里console
它的时候:
listeners: {
load: function (store, records, success) {
console.log(Ext.ComponentQuery.query('combobox[reference=terminal2]')[0])
}
}
我从该组件获得了值,但是当我尝试将它传递给extraParam
时,我得到了错误undefined
。
proxy: {
type: 'ajax',
url: Config.getApi() + 'api/public/index',
extraParams: {
dParams: Ext.ComponentQuery.query('combobox[reference=terminal2]')[0]
},
},
我收到错误undefined
..
我的完整商店代码
Ext.define('Admin.store.npk.mdm.LayananAlat', {
extend: 'Ext.data.Store',
alias: 'store.layananalat',
requires: [
'Config'
],
autoLoad: true,
proxy: {
type: 'ajax',
url: Config.getApi() + 'api/public/index',
actionMethods: {
read: 'POST'
},
paramsAsJson: true,
timeout: 120000,
extraParams: {
dParams: Ext.ComponentQuery.query('combobox[reference=terminal2]')[0]
},
headers: {
'token': Ext.util.Cookies.get('Tokens')
},
reader: {
type: 'json',
rootProperty: function (obj) {
return obj.result
},
totalProperty: function (obj) {
return obj.count
}
}
},
listeners: {
load: function (store, records, success) {
console.log(Ext.ComponentQuery.query('combobox[reference=terminal2]')[0])
}
}
});
或者,是否有其他方法可以在proxy
存储中将动态值传递给extjs中的extraParams
?
发布于 2021-02-05 16:46:16
您的代理设置将在构造阶段设置,此时您的UI很可能未生成,因此您的组件查询无法返回引用的UI元素。
关闭autoLoad
并从存储定义中删除代理零件。然后将代理设置到您可以确保UI已经构造好的位置。例如,在视图的显示/绘制事件上,您可以添加如下代码
const store = Ext.getStore('layananalat');
store.setProxy({
type: 'ajax',
url: Config.getApi() + 'api/public/index',
actionMethods: {
read: 'POST'
},
paramsAsJson: true,
timeout: 120000,
extraParams: {
dParams: Ext.ComponentQuery.query('combobox[reference=terminal2]')[0]
},
headers: {
'token': Ext.util.Cookies.get('Tokens')
},
reader: {
type: 'json',
rootProperty: function (obj) {
return obj.result
},
totalProperty: function (obj) {
return obj.count
}
});
store.load();
https://stackoverflow.com/questions/66064481
复制相似问题