PDA

View Full Version : id's instead of values displayed in comboBox



rac
15 Jun 2010, 12:48 AM
Hello everybody,

I have created an extend of Ext.form.ComboBox for a development that uses a lot of comboBox.
The process is that one :
a server page invoke a stored procedure (sp) to retreive datas according to the parameter it receive (eg. : liste:"rayon"). The fields returns by the sp are always the same : [id] and [libelle].
It work's but in many cases and many combos (not always the same, sometimes yes sometimes no...!) the id (valueField) is displayed instead of the description (displayField).
Here is the code used to create a combo in my application :

{
xtype: "loadListe",
fieldLabel:fiche_article.lbl_rayon,
hiddenName: "ray_id",
id: "lst_rayon",
autoFiltre: false,
liste: "rayon",
cls: "liste"
}

And here is the code of the extension :


Ext.namespace('Ext.tool');
Ext.tool.loadliste = Ext.extend(Ext.form.ComboBox,
{
url : 'loadListe.aspx',
displayField: 'libelle',
valueField: 'id',
autoFiltre: true,
storeField: ['id', 'libelle'],
//param pour l auto completion
queryParam: 'char_filtre',
minChars : 1,
initComponent : function()
{
Ext.tool.loadliste.superclass.initComponent.call(this);

this.initStore();

if(!this.autoFiltre)
{
this.triggerAction = 'all';
this.forceSelection = true;
this.editable = false;
this.mode = 'local';
this.store.load();
}
else
{
this.triggerAction = 'all';
this.mode = 'remote';
}
},

onRender: function(ct, position)
{
Ext.tool.loadliste.superclass.onRender.call(this, ct, position);
},

initStore: function()
{
this.store = new Ext.data.Store
(
{
reader: new Ext.data.XmlReader
(
{
record: 'row'
},
this.storeField
),
proxy: new Ext.data.HttpProxy
(
{
url: this.url
}
),
baseParams:{liste: this.liste}
}
)
}
});

Ext.reg('loadListe', Ext.tool.loadliste);


The xml returned by loadListe.aspx is structured like this :

<?xml version="1.0" encoding="UTF-8"?><dataset>
<row>
<id>2</id>
<libelle>En stock</libelle>
<sta_code>STOCK</sta_code>
<sta_desc>En stock</sta_desc>
</row>
<row>
<id>1</id>
<libelle>Réimpression</libelle>
<sta_code>REIMP</sta_code>
<sta_desc>En réimpression. Disponible sous 2 mois</sta_desc>
</row>
<row>
<id>0</id>
<libelle>Rupture</libelle>
<sta_code>RUPT</sta_code>
<sta_desc>En rupture de stock</sta_desc>
</row>
</dataset>


Any idea woul'd be welcome !!
Thank's in advance for your attention.