PDA

View Full Version : How to display combobox value in a textfield?



sliks
29 Nov 2011, 8:10 AM
Hi, I am still new to ExtJs. There is a question using combobox and textfield.

I have some data in the database. They were set by a combobox in the admin page. In some circumstances, I will need to display a this information based on the database. It has to be read only. How can I do that? If I make it a combobox, the user will be able to edit its content. If I disable the combobox, it becomes grey out. If I make it a textfield, it will become the id of the value.

skirtle
29 Nov 2011, 8:18 AM
Perhaps a read-only combobox?

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.ComboBox-cfg-readOnly

However, this will still present the data like a field and if it really isn't editable this might not make sense. The alternative is just to look up the value in the store and grab the display field from the record. You can then put that value on screen however you want.

sliks
29 Nov 2011, 8:24 AM
Actually I find a config called hideTrigger
By setting it to true, I can make a combobox looks like a textfield.

Thanks anyway!

skirtle
29 Nov 2011, 8:41 AM
Hiding the trigger won't stop them being able to edit the value. Setting readOnly: true also hides the trigger.

sliks
29 Nov 2011, 11:46 AM
Ya that too.

That gave me what I want

Thanks!