PDA

View Full Version : Live search Combobox issue



wisu
23 May 2011, 7:45 PM
Hi all..

I'm using EXTJS 3.3.. setting up live search Combobox with the following code



var storeKota = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({method:'post', url:'/tipe/kota/all/'}),
reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'totalCount',
id: 'id'
}, [{name:'id'},{name:'kota'}])
});

var fieldkota = new Ext.form.ComboBox({
fieldLabel: 'Kota / Kabupaten',
name: 'kota',
store: storeKota,
listeners: {select:{fn:function(combo, record, index) {
var srcRecord = combo.store.getById(combo.getValue());
if(srcRecord) {
var displayField = srcRecord.get('kota');
}
}
}},
mode:'remote',
triggerAction: 'all',
forceSelection: true,
minChars: this.filterChars,
valueField: 'id',
displayField: 'kota',
minListWidth: 400,
width: 400,
minChars: 3
});
Problem is it posts the displayField rather than the valuefield...

Any pointers..

skirtle
23 May 2011, 8:22 PM
What do you mean by 'posts the displayField'?

In the general case, a ComboBox allows the user to type in an arbitrary value, just like a TextField. Under those circumstances it makes sense to submit the display value to the server when the form is submitted as there isn't necessarily a corresponding underlying value.

However, in your case you may find the hiddenName config option helpful. Please refer to the introduction to the docs for ComboBox.

wisu
24 May 2011, 5:34 AM
However, in your case you may find the hiddenName config option helpful. Please refer to the introduction to the docs for ComboBox.


ah.. missed out on that... it works now.... thanks!