29 Apr 2012 10:13 AM #1
Clearing data list in a ComboBox
I have two ComboBoxes in a FormPanel, both using a JsonStore. Let's set it up:
CB1: A list of folders
CB2: A list of users in the selected folder
As of now, when CB1 changes I update and reload the JsonStore behind CB2. This works fine. However - if I change CB1 and press CB2 to show the users in the drop-down, then change CB1 again and want to see users again, the old users are still being shown. If I search for a query or anything (I have typeAhead=true), it loads with the correct data set, but I can't get it to clear that default data set?
I could not find any clearData or the like in Ext.form.ComboBox. Can anyone help me out on this one?
30 Apr 2012 2:49 AM #2
You simply want to remove all records from the store CB2 uses, before then loading in the new data
30 Apr 2012 2:51 AM #3
30 Apr 2012 3:43 AM #4
Removing the records from the store (as you're already attempting) is definitely the correct method, so I wonder if it's something to do with the order in which the events are firing and being acted upon. For the store to reload and retain the existing data also makes me think the previous store params are perhaps not being cleared?
If you could provide any example of your code then I'd happily take a look, but the first steps I would be taking is to debug the store, by console.logging it on each load, clear, etc - and double checking which parameters are being passed to the store during these events.
30 Apr 2012 3:46 AM #5
30 Apr 2012 4:09 AM #6
Without a code snippet it's unfortunately hard to debug what exactly could be going wrong here
Do you have triggerAction: 'all' assigned to your combobox? That's one possible cause for combos only submitting when typing into them, rather than during clicks also...
I'd also take a look at exactly when the combo events are firing. For example "Change" only fires once the combo blurs - which isn't always the preferred event and when actually clicking the combo to select a value. If this is the case, you might instead want to fire the reloading of your second store earlier by using the "Select" event instead.