PDA

View Full Version : Save dynamically created stores to local array and just save them on "Save changes"



schokla
1 Feb 2014, 11:27 AM
I am not sure what to do... I hope one of you has a solution for me... as I am not quite sure if this is the correct approach.

I build a dynamic grid with dynamic columns within a "detail tab" on the basis of a selection of a first grid within the "general tab". WORKING SO FAR!

At the moment I use "removeAll" to clear the existing content of the detail tab and then add the built grid to the container.
The problem is... I would like to save every altered store (that was also dynamically built) to a local array and sync those stores only, when the user presses an own button "save all changes".

My problem: Because of "removeAll" it seems as I lose the existing grid component within the tab container and I am stuck with console errors, as the grid is not defined anymore when I want to add it to the container.

The first creation it works fine, but the second crashes, as the grid is gone... btw... if I remove the "removeAll" from the container, I don't get any error anymore, but as a result, I get an additional grid added below the existing one(s)... which is definitely NOT what I want.

Do you have any solutions or best practice approaches for me? How can I meet this requirement?
Thanks for your help!

greg.barry
6 Feb 2014, 12:20 PM
It sounds like you're most likely experiencing ID collisions.

removeAll() does not necessarily destroy the components you're removing. So you're creating a component and I'm guessing you have an ID config on said component. Then, you're doing a removeAll(). The component disappears, but it's not destroyed. Then, you try to create another one, but there's a duplicate colliding with it.

To remedy this, you can try to do: removeAll(true). This will necessitate that what ever components were removed are also destroyed.

You can read more about removeAll() here:
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.container.AbstractContainer-method-removeAll

Thanks!
Greg