View Full Version : How do you change a form panel layout after it has been rendered ?

27 Sep 2011, 1:47 AM
i tried,

var p = Ext.getCmp("filter_formPanel");

p.layout = {type: "accordion"};

p.layoutConfig = {
titleCollapse: false,
animate: true,
activeOnTop: true

No Luck

Thanks for any help

27 Sep 2011, 3:13 AM
It might be possible but if I were you I'd just recreate the parent container. If that's problematic for some reason you might need to add in an extra level of container just so that you can destroy/recreate it.

27 Sep 2011, 8:19 AM
i have one function which replaces forms on pages with extjs form panel and all inputs, thing is i have to write this function every time there is a special custom form or something is special in form layout, i would love to have only one function that converts forms and then extract the panel and modify the layout rather than writing a whole new search and replace script, that would be more effective.

Now i have to write a new search and replace script every time i need to replace a form and then i can happily lay it out on its definition config.

Why canít you access properties like .margin etc and doLayout it doesnít work, you should in theory be able to Iím guessing itís too difficult to manipulate the dom for the framework?

Thanks again

28 Sep 2011, 1:24 AM
The layout configuration options are used to create a layout manager object when the component is created. Trying to set those options subsequently won't have any effect, the layout manager won't be recreated.

I can think of a few reasons the framework doesn't support a technique to change layouts...

It's not a common requirement. I don't recall having seen this requested before.
Layouts are already pretty complicated without trying to add support for switching them.
There's a pretty simple workaround.

I'm not sure I understand why you can't use the workaround I suggested. Just recreate the container with the new layout. You need to be careful move the children in such a way that they don't get destroyed but it really shouldn't be difficult.

nareh tank
29 Sep 2011, 10:21 PM
i also want to change layout on action call and remove child control and add new with different layout.
is it possible or not and is yes then how ?


30 Sep 2011, 2:49 AM
Not 100% sure what you're trying to do but...

To remove the children you'll need remove(), being careful to not destroy the children:


To add them back into the new container:


Give it a go and if you can't get it to work then post your best attempt and we can try to help you get it working.