PDA

View Full Version : How to set values for the xtype selectfield with a store



Flipfine
5 Dec 2011, 1:09 PM
Hi Sencha User,

how you can see in the title I have a store with datafields which I want to use to set the values of a selectfield.
It's a xtype declaration. Do you have a example for me ?

Thanks

mitchellsimoens
5 Dec 2011, 2:06 PM
To get the display field value to show on the select field, the store must be loaded when the value gets applied to the select field.

Flipfine
5 Dec 2011, 10:50 PM
Okay, but how it look to set e.g. the datepickerfield with a date of a store
when the store is loaded. Perhaps you can show me a little code example :)

Sameer Khan
8 Dec 2011, 9:33 PM
Sample:
1. Ext.regModel('JobType', {
idProperty:'id',
fields:[
{name:'id',type:'int'},
{name:'Description',type:'string'},
]});


2. this.jobtype= Ext.StoreMgr.lookup('jobtypestore');
if(this.jobtype.data.length==0){
this.jobtype = new Ext.data.ArrayStore({
model: 'JobType',
data : [['Update JobTypes ','Update JobTypes']]
});
}

3. var items=[{
xtype: 'selectfield',
labelWidth:'35%',
labelAlign: 'left',
label: 'Job Type',
name: 'jobtype',
displayField:'Description',
valueField:'Description',
store:this.jobtype,
required:true,
}]
4. panel.add(items);panel.show();