PDA

View Full Version : Copying conents of Parent window in child window



AJAIN32
11 Jun 2015, 6:26 AM
Hi All,

I am using a window(Ext.window.Window) component and i am showing this window on the click of one button in the main window(parent window).
I want to copy all the contents from the parent window to the child window on a placeholder. but after that i want to hide some elements on the child window as well.
I tried some of the solutions which are not working -

adding the view in the child window's container (placeholder), but when i do this i get the view on the child window as it is but it is being hidden from the main window.
insert the view in the container - it is also not working
cloneConfig() - I am not sure how to use it, i tried this taking the reference of main window component but no luck as its giving some error of duplicate id's (we have configured id's with some of the elements in the main window).
can anyone please suggest how to deal with this without having much changes in the main window. Any suggestions would be helpful

Thanks,
Ankit

tristan.lee
12 Jun 2015, 6:50 AM
Can you provide a code sample with what you've tried so I can work with you to resolve this?

jdkhamba
13 Jun 2015, 3:35 PM
Windows are in essence floating components. So I am not sure what you mean when you say one window is "inside" another. You might wanna use a different design approach where both these windows are two separate views that are manipulated by the controller in your application. It is possible to position the child window in such a way that it "appears" inside the parent window using various position related configs/method such as showAt but the child window could be just another window.

You could create one window class and based on the config provided, only the items that you need would be created for that window. If the items in both windows are independent, then there is no need to carry over anything from parent window to child window.But if the child window contents are somehow dependent on the parent window's items collection, then just loop through each item and call cloneConfig() on each of them, and add it to some array that can be later passed as parameter to the controller's listener. (parent.fireEvent('parent-button-clicked',itemsArray).

This should get you started but for any real help you would also need to post your code.

AJAIN32
15 Jun 2015, 5:38 AM
Thanks for replying,

I Apologise because i have not provided any code blocks here.as its a huge code what i am trying to reuse in another window. I will try to use fiddle to see if it works to highlight the issue.

The contents of the second window is dependent on the first window.I was creating the multiple object for the same class to generate the view in which i was facing some issues with the id's which we have provided to some of the components.I have tried cloneConfig and there is a way to override the id part as well. I will give it a try and update here accordingly.

can anyone please tell me while creating an object of the class (.js files) how can i override some components inside that class to eliminate the id's in some components ? or the cloneConfig is the best approach to go with ?

Thanks,
Ankit

tristan.lee
16 Jun 2015, 7:40 AM
Are you not able to specify unique IDs? Using cloneConfig() you can pass in an object containing any overrides.

AJAIN32
16 Jun 2015, 8:03 AM
Thanks Tristan for Replying,

casn you please help me to understand the usage of cloneConfig function.
I want to create 2 seperate objects of the same extjs class, what i have in the class is - some components which has the id configured, now i am trying to clone the object2 with object1 and if i write - obj2 = obj1.cloneConfig() it will throw the error of "registering the duplicate id".
can you please suggest any simple example or sample in which i can override some of the components of obj1 in obj2 (basically overriding the id's of some component).

Please suggest !!

Thanks,
Ankit

tristan.lee
16 Jun 2015, 11:50 AM
You should be able to do:

var obj2 = obj1.cloneConfig({id: 'newId'});

AJAIN32
16 Jun 2015, 12:00 PM
Thanks for replying,

I think, i have missed something while explaining the issue.
In Object1 i have sevral components, out of which i need to change id of one component, so it's not about overriding the id of main object which we are copying. we want to override one of the component of the object which we want to clone.

Any suggestions about how we can override the nested objects in it ??

Thanks,
Ankit

tristan.lee
16 Jun 2015, 12:37 PM
Can you create a basic fiddle reproducing the issue you're facing so I can work along with you? I have an idea of what you want, but without seeing the code, it's hard to give a working solution.

AJAIN32
16 Jun 2015, 6:38 PM
Thanks,

Sure, I will give it a try in fiddle and let you know if i can reproduce it.

Thanks,
Ankit