PDA

View Full Version : Combo with local data: allQuery wrong sort order of values added dynamically



yyogev
20 Jun 2012, 8:18 AM
Hello,

I have a combo box inside a grid with cell editing plugin. The logic of the application is such that when a certain option X is selected, I add to the combo option "X #2", and when "X #2 is selected I add option "X #3, and so on.

The store uses local data which is provided by the page on load.

After the new record is added to the store, the next time I open the combo drop-down list by clicking the trigger button ("allQuery"), the list appears to remain unchanged. When looking further, I see that the newly added option was added at the end of the list, regardless of the way the store is sorted.
However, if I enter text in the combo the filtered list shows the newly added option in the proper location.

Thanks,

yyogev
20 Jun 2012, 9:22 PM
I tried

combo.lastQuery = null;
but it did not work either.

Any other ideas ?


Thanks,

scottmartin
21 Jun 2012, 7:36 AM
Can you put together a small working example?

Regards,
Scott.

yyogev
24 Jun 2012, 1:55 AM
When I tried to simulate this using the combos.js example, I was able to make it work by using sort() on the combo store after adding the new entries. However, I am still unable to make it work in my application.

See attached examples files.

Thanks,

Animal
24 Jun 2012, 8:22 AM
If it's a remote combo, then it gets loaded each time. Any added records will go.

yyogev
24 Jun 2012, 8:31 AM
As said above, the store uses local data. The problem is that there are many records in the store - more than 50 for sure. The added entries appear at the end of the list rather then in the proper place, which made me think at first that they were not shown at all. The store is created with the appropriate sorters, and I also tried using store.sort() following the store.add(), but no joy.

Thanks,

Animal
25 Jun 2012, 2:36 AM
It works as expected.

I took your example, typed the following into the console:



c=Ext.getCmp('combobox-1001');
s=c.store;
s.add([{abbr:'WD', name:'Wonky Donkey', slogan:'Wonkey Donkeys!'}]);


And when I clicked the trigger, it displays in the correct sorted order:

https://s3.amazonaws.com/uploads.hipchat.com/9804/25186/8guqo421tnfxf7n/Screen%20Shot%202012-06-25%20at%2011.36.36.png

yyogev
25 Jun 2012, 3:20 AM
It now works: I removed the redundant firing of datachanged event, as well as the resetting of lastQuery.
Not sure why I added them in the first place :-?

Thanks,