PDA

View Full Version : Extjs Dropdown issue



AJAIN32
20 Aug 2014, 1:57 AM
Hi,

I have a situation in which i am using a combobox and i have code text pair for data.
let me explain the issue with example -

for example i have two code text pair for the dropdown -
code : o text : open , code: c text: closed
and i need to show these two pairs in the dropdown in the code-text (o-open) format. i did that by modifing the text before binding and i am able to set the text as required.
if i select any of the value from the dropdown it should show only code value (o in case of open) that i am trying to do with displayTpl.
with displayTpl i am able to show only code after selecting, but the dropdown is not allowing any other value except the codes present in the dropdown.
its a editable combobox where i can write anything and update it.
displayTpl : Ext.create('Ext.XTemplate',
'<tpl for = ".">',
'{code}'
'</tpl>')

Please help and suggest how i can use displayTpl or anything else for this situation.

Thanks,
Ankit

chamacs
20 Aug 2014, 1:21 PM
You could try this:


displayField : 'code',
listConfig: {
getInnerTpl : function(){
return '{code}-{text}';
}
}

AJAIN32
20 Aug 2014, 8:24 PM
Thanks for replying,

can you please briefly tell me about the tpl,displayTpl and getInnerTpl. excactly how it works.

This code worked fine for me :)

displayField : 'code',
listConfig: {
getInnerTpl : function(){
return '{code}-{text}';
}
}

can i check code value before returning, for example for one code text pair i am having code as blank("") and text as closed so i want some different representation like -

getInnerTpl : function(){
if({code} != "")
return '{code}-{text}';
else
return {text}

but the condition is not correct. can you please suggest ?

Thanks
Ankit

skirtle
20 Aug 2014, 9:33 PM
The returned string is included in an XTemplate so you would do the conditioning within the string using XTemplate syntax.