admin管理员组文章数量:1279083
I want to dynamically add items to a bo box item. This is how its defined:
{
xtype: 'bobox',
id: 'tierTypeCB',
fieldLabel: 'Tiers\' type',
labelWidth: 70,
editable: false,
valueField: 'type',
displayField: 'type',
store: Ext.create('Ext.data.Store',{
fields: ['type'],
data: []
})
}
In other part of the code, I have this function which is supposed to add the items:
onGetTiersSuccess: function(response) { // this is a 'success' function of an AJAX request
var decodedResponse = Ext.decode(response.responseText);
var tierTypeCB = Ext.getCmp('tierTypeCB');
var tierTypesStore = tierTypeCB.getStore();
for (var tierType in decodedResponse){
tierTypesStore .add({type: tierType});
}
}
The thing is that when the drop-down is opened its empty. what i've found out, is that my code puts the data into the bo-box's store, but once the bo is expanded the store is emptied.
I've done some more testing using chrome's console. I mented-out the 'onGetTiersSuccess' function. Instead I just type into the console Ext.getCmp('tierTypeCB').getStore().add({type: 'abc'})
If I open the bo-box its empty. However, if I first open the bo-box (before adding that item), and only then add the item, once I open the bo-box again I can see there the item I've added.
It seems that adding item to the bo-box before opening it, 'resets' the bo-box's store once its opened.
I've tried to by-pass it by calling Ext.getCmp('tierTypeCB').expand()
and then calling Ext.getCmp('tierTypeCB').collapse()
before adding the items, but that didn't help.
i've also tried not setting the bo-box's store where i define it, but create a store object and then bind it to the bo-box (using the bindStore()
mand) and that didn't help either.
At this point I'm clueless, so I'd appreciate it if you have any idea that might help me.
Thanks, eRez
I want to dynamically add items to a bo box item. This is how its defined:
{
xtype: 'bobox',
id: 'tierTypeCB',
fieldLabel: 'Tiers\' type',
labelWidth: 70,
editable: false,
valueField: 'type',
displayField: 'type',
store: Ext.create('Ext.data.Store',{
fields: ['type'],
data: []
})
}
In other part of the code, I have this function which is supposed to add the items:
onGetTiersSuccess: function(response) { // this is a 'success' function of an AJAX request
var decodedResponse = Ext.decode(response.responseText);
var tierTypeCB = Ext.getCmp('tierTypeCB');
var tierTypesStore = tierTypeCB.getStore();
for (var tierType in decodedResponse){
tierTypesStore .add({type: tierType});
}
}
The thing is that when the drop-down is opened its empty. what i've found out, is that my code puts the data into the bo-box's store, but once the bo is expanded the store is emptied.
I've done some more testing using chrome's console. I mented-out the 'onGetTiersSuccess' function. Instead I just type into the console Ext.getCmp('tierTypeCB').getStore().add({type: 'abc'})
If I open the bo-box its empty. However, if I first open the bo-box (before adding that item), and only then add the item, once I open the bo-box again I can see there the item I've added.
It seems that adding item to the bo-box before opening it, 'resets' the bo-box's store once its opened.
I've tried to by-pass it by calling Ext.getCmp('tierTypeCB').expand()
and then calling Ext.getCmp('tierTypeCB').collapse()
before adding the items, but that didn't help.
i've also tried not setting the bo-box's store where i define it, but create a store object and then bind it to the bo-box (using the bindStore()
mand) and that didn't help either.
At this point I'm clueless, so I'd appreciate it if you have any idea that might help me.
Thanks, eRez
Share Improve this question edited Jul 31, 2013 at 14:20 Jeff Shaver 3,35520 silver badges19 bronze badges asked Jul 31, 2013 at 14:02 eRezeRez 25710 silver badges24 bronze badges 02 Answers
Reset to default 7You should be able to use the lastQuery
config of the bo to keep the store from reloading when first expanded.
{
xtype: 'bobox',
lastQuery: '',
id: 'tierTypeCB',
fieldLabel: 'Tiers\' type',
labelWidth: 70,
editable: false,
valueField: 'type',
displayField: 'type',
store: Ext.create('Ext.data.Store',{
fields: ['type'],
data: []
})
}
See the docs here: http://docs.sencha./extjs/4.2.1/#!/api/Ext.form.field.ComboBox-property-lastQuery
Set the queryMode
property to local
. What is happening is the empty store isn't being created until you try to expand the bobox. The queryMode
property is, by default, remote
. Setting it to local
should fix the issue because it will load the store when the bobox is created.
本文标签: javascriptEXTJS combobox39s store reset after expand when data is loaded dynamicallyStack Overflow
版权声明:本文标题:javascript - EXT-JS combo-box's store reset after expand when data is loaded dynamically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741288386a2370405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论