Search code examples
c#dynamicext.net

Add new Window from C# Code-Behind in ext.net


I'd like to add a new Window with working Listeners and DirectEvents from code-behind to realize an admin-interface on Button-Click. So far I have following Code (minimalized):

Window editwindow = new Window(){
   ID="Window_Edit",
   width = 380,
   height = 120,
   hidden = false
};
FormPanel editpanel = new FormPanel(){
   ID="Panel_Edit"
}; 
editpanel.Items.Add(new TextField(){
   ID="Edit_Fieldname",
   FieldLabel = "Some Label",
   LabelStyle="text-align:right;",
   Width = 260,
   LabelWidth=120
});
editwindow.Add(editpanel);
this.Page.Controls.Add(editwindow);
//Viewport.Add(editwindow); Viewport is a wrapping <ext:Container>
//editwindow.DoLayout(); this has been throwing a reference error on client-side

I'd like to know how I can make the window be displayed. Right now if I inspect the execution with firebug a status code 200: OK is returned on the Post Request. But I do a Store operation some lines before that, and the response does not Contain these Store Changes!

The funny thing now is, that changing the triggering Button's Text works without fault, so I am sure a full reload is not executed.


Solution

  • I'm making a few assumptions with my response because you have not posted a sample demonstrating the whole scenario, but I think revising to the following should work:

    // Old
    // editwindow.Add(editpanel);
    // this.Page.Controls.Add(editwindow);
    
    // New
    editwindow.Items.Add(editpanel);
    editwindow.Render(this.Form);
    

    The following sample also demonstrates the scenario of dynamically creating a Window during a DirectEvent and adding the , see

    http://examples.ext.net/#/XRender/Basic/New_Window/

    Hope this helps.