View Full Version : How to format the Content of a Combobox

2 Dec 2010, 3:53 PM
Hello, i've got a little problem. I hav a grid and combobox (not in the grid linke editable girds). Both components share one store. If the Grid reload data, the content of the combobox is updated to. Ok, thats what i want. now, i have a special column in the grid and this column or better the datafield behind the column is the displayField in my combobox. for the column in the grid i have a spezial renderer to add additional information in breackets behind the value and this informations depends on the value (for example, I whant do generate the string "ONE" for the value 1 or the string "TEN" for the value 10). In the grid it is no problem but it is a problem in my combobox because i could only display the value from the store an did not have any possibillitys to call a renderer funktionc. i tryed to solve this with a template but without results. I tryed like this:

tpl: '<tpl for="."><div class="x-combo-list-item"><script type="text/javascript">document.write(MyRenderFunction{"' + this.displayField + '"});<script></div></tpl>'

or like this

tpl: '<tpl for="."><div class="x-combo-list-item"><div id="MyValue{' + this.displayField + '}"></div><script type="text/javascript">document.getElementById(' + this.displayField + ').innerHtml = MyRenderFunction{"' + this.displayField + '"};<script></div></tpl>'

I know... that looks very evil, but i tryed to go any way I could imagin.
Did you have any idear, how to solve my problem?

3 Dec 2010, 4:50 AM
So you want:

tpl: '<tpl for="."><div class="x-combo-list-item">{[MyRenderFunction(values.' + this.displayField + ')]}</div></tpl>'

ps. Does 'this.displayField' actually contain the correct field name?

3 Dec 2010, 5:40 AM
Yes, this.displayField is the fieldname from the store, i would like do transform and show in my combobox, but your solution did not work. in my render-function not the raw value is delivered. the function becomes "undefined" as paramvalue, but now i am a step closer to my solution.

did you know, wy undefined is delivered?

3 Dec 2010, 5:52 AM
Ok, I've got it. the value in this.displayField is strange so I write the the name of the fieldname instat like:

tpl: '<tpl for="."><div class="x-combo-list-item">{[MyRenderFunction(values.MyFieldNameToRender)]}</div></tpl>',

and know it works

Thank you very much!

3 Dec 2010, 5:59 AM
Are you absolutely sure that this.displayField is the displayField at that point (maybe post some more code)?

3 Dec 2010, 7:25 AM
Yes. for my solution i copyed the value from displayField to my template (so it could not a mistake in spelling) and now it works. but i think it's not important because now all is fine ;)