PDA

View Full Version : How to customize Combo displayField rendering



oopkid
29 Jun 2010, 8:18 PM
I want my combo to display a concatenation of two model attributes (like id - code )



xtype: 'combo',
mode: 'local',
store: new Ext.data.Store({
autoLoad: true,
fields: ['id', 'code'],
proxy: new Ext.data.HttpProxy({
url: 'xxx.do?method=mmm'
}),
reader: new Ext.data.JsonReader({
root: 'data'
},[
{name: 'id', mapping: 'id'},
{name: 'code', mapping: 'code'}
])
}),
displayField: 'code', // want to concatenate id and code
valueField: 'id',
.
.


It's possible ? If yes, can you give an example please..

4 Jul 2010, 8:46 AM
Look at the "Custom combo box" example

http://www.sencha.com/deploy/dev/examples/form/forum-search.html

oopkid
9 Jul 2010, 12:50 AM
Thank a lot .. Garcia

I follow sample code above. Like this


// Custom rendering Template
var codeTpl = '<tpl for=".">{id} - {code}</tpl>';
var resultTpl = new Ext.XTemplate(
codeTpl
);

store: new Ext.data.Store({
autoLoad: true,
fields: ['id', 'code'],
proxy: new Ext.data.HttpProxy({
url: 'xxx.do?method=mmm'
}),
reader: new Ext.data.JsonReader({
root: 'data'
},[
{name: 'id', mapping: 'id'},
{name: 'code', mapping: 'code'}
])
}),
displayField: 'code', // want to concatenate id and code
valueField: 'id',
tpl: resultTpl,
.
.


Display field is look good but i can't select in combobox !!
What am I doing wrong ? Please suggest me ..