-
Ext JS Premium Member
Change form element types on the fly?
In an attempt to reuse a form I have a need where in some cases I might want to change a plain TextField to a ComboBox as the entry/selection tool for the same data value.
If I initially configure the field as as a TextField, how might I go about replacing that field with a ComboBox at runtime if special conditions warrant doing so.
I realize I could probably just present an empty enterable combo in lieu of a TextField, but in the majority of cases a normal TextField will be more appropriate.
I'm assuming this is possible (this is ExtJS). Just looking for hints about how to approach the problem.
-
Sencha User
There's nothing built in to do that. You could theoretically render both fields, make one hidden, then show it when needed, possibly changing it's position so that it appears in the same place. You could also write some sort of 'replace' function that removes the old field, adds a new one and calls doLayout.
-
Ext JS Premium Member
Tim,
Thanks for the hints and the confirmation that a built-in solution doesn't exist. I've already played with your first suggestion (toggling the visibility of two fields) and getting the result I want wasn't as straightforward or simple as I'd hoped. There is some extra work involved to also show/hide labels.
I'll look into your replace suggestion.
-
Another solution would be to use a combobox all the time, but hide the trigger if it isn't used.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules