PDA

View Full Version : Select first record on from store on comboboxload



TrickOfTheMind
30 Jun 2008, 7:41 AM
Is there an easy way to do this without adding a listener for the appriorate load event, basically select first record from store on combobox load.. I guess I'm looking for .selectedIndex = 0 (I dont know the value/key usually).

30 Jun 2008, 8:33 AM
Is there an easy way to do this without adding a listener for the appriorate load event, basically select first record from store on combobox load.. I guess I'm looking for .selectedIndex = 0 (I dont know the value/key usually).

the load is asynchronous. You'll need to listen to the load event.

mthad
6 Jul 2008, 12:19 PM
the load is asynchronous. You'll need to listen to the load event.

How can i set the load event? I mean where? Please send me the sample code.

thanks,

6 Jul 2008, 12:52 PM
yourStore.on('load', function() {
yourCombo.setValue(yourStore.data.items.items[0].data.someAttribute);
});

mthad
6 Jul 2008, 1:04 PM
yourStore.on('load', function() {
yourCombo.setValue(yourStore.data.items.items[0].data.someAttribute);
});


it is working but the item (onload-->selected) in the combobox is not highlighted. I mean when i click on drop-downlist, the default selected item in the list is not hightlighted. Example: I choose items[53] from the list, but the cursor/highlighted at the items[0]. How can i do that?

6 Jul 2008, 1:13 PM
Not too sure. But why would you want to show the selected value? It should already be in the input box!

mthad
6 Jul 2008, 1:15 PM
Not too sure. But why would you want to show the selected value? It should already be in the input box!


That is the requirement. When the user click on drop-down list, the default selected item should be highlighted in the list.

6 Jul 2008, 1:21 PM
i've not personally done it. but i would suggest looking at the list template. If i had time, i'd investigate further. :-\

mthad
6 Jul 2008, 1:36 PM
i've not personally done it. but i would suggest looking at the list template. If i had time, i'd investigate further. :-\


Thanks for your time!!!

mthad
6 Jul 2008, 1:40 PM
yourStore.on('load', function() {
yourCombo.setValue(yourStore.data.items.items[0].data.someAttribute);
});


Just realised, i want to run the below code on form-load instead of datastore load. How can i do this? I can see the default value after i click on combobox. But i want to display when form loads.


dsInforSource.on('load', function() {
infoSourcecombo.setValue(dsInforSource.data.items[53].data.reaction);
});