views:

47

answers:

2

So here is the situation. I have a button on one of my extjs pages. This button opens a child window as a pop-up. This child window has a .method attribute as well as a .ref attribute, and also a .id. I need the functionality to open another window with the SAME template, everytime I click that button.

I was thinking set the childwindow .method property to something like 'getWindow', and the .ref to something like 'newWindow' and then create a javascript function on the backend to look something like this:

var myArray = [];
var count = 0;
function getWindow() {
    newWindow.Id = count;
    getWindow().show();
    myArray[count] = count;
    count++;
}

Would this work?

Edit:

Using ViewDetailsWin As New Pages.ChildWindow
        With ViewDetailsWin
            .Id = "Test"
            .IconCls = Model.WorkflowStepDefinition.SmallIcon
            .Ref = "viewDetailsWin"
            .RenderTo = "workspacePanel.getEl()"
            .DestroyerRef = "mainPanel"
            .MethodName = "getViewDetailsWin"
            .Title = "View Details/Amortization Schedule"
            .Layout = Pages.Panel.LayoutType.Fit
            .Closable = True
            .CloseAction = Pages.Window.CloseActionType.Hide
            .Minimizable = True
            .Modal = False
            .Height = 700
            .Width = 1000
            .BodyStyle = "padding:10px"

There is more to it....

A: 

What do you mean by same template? Do you want an exact same window on clicking that button? Then create a Ext.Window component and create a new instance every time the button is clicked.

For example:

MyWindow = Ext.extend(Ext.Window, {
    width: 300,
    height: 300,
    title : 'my window',
    ref: 'whatever',
    method: function(){},
    initComponent: function () {
        MyWindow.superclass.initComponent.call(this);
    }
});

function createWindow(){
     var win = new MyWindow();
     win.show();
}

On click of the button call this createWindow function. Now to keep track of all the Windows, have a look at the WindowGroup or WindowMgr component of ExtJS.

Swar
It's the second part of the comment that I do not know how to accomplish. Our child window class is an ExtWindow component. But how do I create a new instance everytime the button is clicked and display it.
Scott
Right now the button control that opens the window looks like this '.AddButton("View Details/Amortization Schedule", "function(){getViewDetailsWin().show();}", "icon-button-edit", "View Details", "Can open multiple windows...").Disabled = Model.IsUserReadOnly'. That only opens one window and when I click it again it does nothing.
Scott
I have given a code sample. Try that.
Swar
okay that kind of makes sense, however look at my recent edit, on the front end I have described the window. How to I open THAT one multiple times, with that same format.
Scott
I don't recognize the format you have given - is it GWT? However, if you specify an ID to it, then you cannot create multiple windows. remove the id part or use Ext.id() function for ID. And creating a reusable component as I gave is the best option to achieve the functionality you want. Otherwise, you can put this code in the function you are calling on button click. It will create a new window every-time. Remember not to to hardcode an ID attribute.
Swar
A: 

I went a different route. I created another View called 'Details.aspx' in the same MVC folder. Then with Javascript I just open that view as a popup each time.

Scott