PDA

View Full Version : getting object refs between overlapped modal windows



Shining77
14 Dec 2010, 8:50 AM
Following difficult case with 3 windows (App.ux.window is an own Ext.Window extension):

App.publisherRevenueShareEdit.window = Ext.extend(App.ux.window, {
...
,listeners: {
,save: function() {
...
}

,initComponent: function() {

this.items = [{
xtype: 'form'
...
});


App.publisherRevenueShares.window = Ext.extend(App.ux.window, {
...
initComponent: function() {

this.items = [{
xtype: 'grid'
... // somewhere opening new App.publisherRevenueShareEdit.window for editing
});


App.publisher.window = Ext.extend(App.ux.window, {
...
initComponent: function() {

this.items = [
{
xtype: 'form',
...
{
xtype: 'textfield',
buttons: {
handler: function(button, field, event)
{
var win = new App.publisherRevenueShares.window();
win.show();
....

Case is the following:

I have the window App.publisher.window with a form with a textfield (which only displaying a value and is disabled) and one button to edit align right from it. By clicking on this button, I open a new modal window App.publisherRevenueShares.window which contains a new grid. There I have to edit one row by opening another new modal window App.publisherRevenueShareEdit.window which contains a form and a save listener.
In this save function I do not want to save the values only but also to refresh the value of the textfield from my first window.

Now is my question: How can I get access to this textfield? I have tried very much in the save function with ownerCt and stuff... but was not really successful.

Can anybody help with that? I do not want to use ids here only itemIds

Ballsacian1
14 Dec 2010, 10:18 AM
You could setup an event on App.publisherRevenueShareEdit.window which bubbles up all the way to App.publisher.window. From my understanding if you add a window to a component things like event bubbling, ownerCt, and ref / refOwner all get resolved even though the window is standalone and is not controlled by the container.

Shining77
14 Dec 2010, 10:37 AM
thanks for the tipp with the bubbling. Unfortunately I did not have worked with that. What might this look like in my code? Is it this config-option bubbleEvents?

Ballsacian1
14 Dec 2010, 10:53 AM
Check out the source code to see how you can use enableBubble and getBubbleTarget. At it's most basic level using enableBubble will just fire the event on ownerCt; so if you have every window added into its parent windows container then the events will bubble up naturally.

http://dev.sencha.com/deploy/dev/docs/source/Observable-more.html#method-Ext.util.Observable-enableBubble



App.publisher.window = Ext.extend(App.ux.window, {
...
initComponent: function() {
this.listeners: {
revenueedit : this.doWhatever
}
this.items = [
{
xtype: 'form',
...
{
xtype: 'textfield',
buttons: {
handler: function(button, field, event)
{
var win = new App.publisherRevenueShares.window();
appPubWindow.add(win);
win.show();




xtype: 'grid',
initComponent: function() {
this.enableBubble('revenueedit');
}
... // somewhere opening new App.publisherRevenueShareEdit.window for editing
doEdit : function(){
var win = new App.publisherRevenueShareEdit.window();
appPubRevSharesWindow.add(win);
win.show();
}




App.publisherRevenueShareEdit.window = Ext.extend(App.ux.window, {
initComponent: function() {
this.enableBubble('revenueedit');
}
}