-
28 Dec 2010 11:10 PM #1
ComboBox : using select () to select the first item from the store.
ComboBox : using select () to select the first item from the store.
Hi,
I need to set the first item from the store as the selected item in the combobox as soon as the form opens .
But this shows an error in the firebugCode:cro_store=new Ext.data.JsonStore({ url:base_root+"php/cce_target_achievement.php", id:'cro_store', totalProperty:'totalCount', root:'qry', fields:['user_id','name'], baseParams:{task:'GET_CRO'} }); cro_store.load(); cro_combo=new Ext.form.ComboBox({ id:'cro_combo', fieldLabel:'CROs', store:cro_store, mode:'remote', typeAhead: true, anchor:'100%', triggerAction: 'all', displayField:'name', valueField:'user_id', emptyText:'CROs' }); cro_combo.select(0);
I cannot use setValue and selectByValue as the datas are dynamic.Code:this.view is undefined Ext.form.ComboBox=Ext.extend(Ext.form....);Ext.reg("combo",Ext.form.ComboBox);
-
28 Dec 2010 11:49 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
No, don't use select() or selectByValue() (I don't even know why these methods are documented as public - you should never use them).
Instead, use setValue().
ps. Don't forget that you have to wait for the store to load before you can select the first entry!
-
29 Dec 2010 2:19 AM #3
Thank you for the reply Condor. To use the setValue() method i need to know the values that are currently loaded in the store. But what if the values are dynamic ? I mean what if the values keep changing.
I just want to select the first value which ever comes first in th store .
Thank you...
-
29 Dec 2010 2:32 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Code:cro_store.load({ callback: function(){ cro_combo.setValue(cro_store.getAt(0).get('user_id')); } });
-
29 Dec 2010 2:49 AM #5
Thank you. I think i need to read the docs a lot. Its working
Similar Threads
-
by default select first item for combobox having array as store
By santoshsatav in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 2 Dec 2010, 10:39 AM -
[SOLVED] I cant select the item on Combobox
By Jamiroquai in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 4 Nov 2008, 7:11 AM -
Select automatically one item in a ComboBox
By junkzilla in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 4 Aug 2008, 9:05 PM -
ComboBox select first Item
By pauleee in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 29 May 2008, 5:03 AM -
ComboBox select item fact ....
By armandoxxx in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 14 May 2008, 4:15 AM



Reply With Quote