PDA

View Full Version : Modify existing form field



PV-Patrick
20 Jul 2009, 9:43 AM
Is it possible to modify an existing field item? I am looking to dynamically change between a text field and combobox based on a record in a datastore being loaded. Is it possible to do this? Maybe even just give the item: {id: testitem} and no other properties.... Any clarification on this would be much appreciated, thank you!

eschuy
20 Jul 2009, 10:00 AM
I've done something similar. I'm not sure if it's the best practice but what I do is on load I analyze the record, them edit the form accordingly (removing/adding the corresponding fields)

PV-Patrick
20 Jul 2009, 10:07 AM
I did eventually find some work-arounds for adding/removing form items from a specific location. IE: https://extjs.com/forum/showthread.php?p=85169

However, is this current practice? Is there something built into Ext that allows you to add/remove a field from a spcific location to maintain a desired field order? Thanks!

eschuy
20 Jul 2009, 10:08 AM
There's an insert() function, if that's what you mean.

PV-Patrick
20 Jul 2009, 10:11 AM
That might be exactly what I was looking for... I can't believe I missed that. I have been going over the docs for a few hours now...lol.

eschuy
20 Jul 2009, 10:16 AM
... I have been going over the docs for a few hours now...lol.

It happens, just remember to .doLayout() after doing your field juggles, or it won't show on screen.

PV-Patrick
20 Jul 2009, 10:18 AM
That was exactly what I needed, thank you eschuy! Essientially what I am doing is loading a Region field based on a selected Country, region can either be a combo box filled with predefined regions/states/provinces, or it can be a text field.