[CLOSED] Added object to already create window

  1. #1

    [CLOSED] Added object to already create window

    Hello

    Continuing with my chart system, now, I will add the panel containing the chart directly in an existing window creating in apx page like that:

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="Ext.Net.Utilities"%>
    <%@ Import Namespace="Panel=Ext.Net.Panel" %>
    <%@ Import Namespace="Chart=Ext.Net.Chart" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
        <script runat="server">
         protected void Page_Load(object sender,EventArgs e)
            {
                // Load the data into the Store and DataBind. 
                this.stoCharts.DataSource = this.stoChartsValue;
                this.stoCharts.DataBind();
    
              
            }
    
         private object[] stoChartsValue
        {
            get
            {
                return new object[]
                {
                    new object[] {"2011/01/01",10},
                    new object[] {"2011/02/01",15},
                    new object[] {"2011/03/01",21},
                    new object[] {"2011/04/01",1},
                    new object[] {"2011/05/01",18},
                    new object[] {"2011/06/01",30},
                    new object[] {"2011/07/01",25},
                    new object[] {"2011/08/01",14},
                    new object[] {"2011/09/01",11},
                    new object[] {"2011/10/01",9},
                    new object[] {"2011/11/01",3},
                    new object[] {"2011/12/01",45}           
                };
            }
        }
    
    
         protected void TestCharts(object sender, EventArgs e)
         {
             Window myWindow = MyDesktop.Modules('Dashboard').Window(0);
             myWindow.Add(BuildPanel());
         }
     
    
         private Chart BuildChart() 
           {
                Chart MyChart = new Chart();
                AxisCollection MyAxes=new AxisCollection();
                CategoryAxis AxesX =new CategoryAxis();
                NumericAxis AxesY= new NumericAxis();
                LineSeries MySerie=new LineSeries();
                                      
                AxesX.Title = "Month";
                AxesX.Fields = new string[1];
                AxesX.Fields[0] = "Date";
                
                AxesY.Minimum = 0;
                AxesY.Fields = new string[1];
                AxesY.Fields[0] = "Value";
    
                MyAxes.Add(AxesX);
                MyAxes.Add(AxesY);
    
                MySerie.SeriesID = "IdSerie";
                MySerie.Axis = Position.Left;
                MySerie.XField = new string[1];
                MySerie.XField[0] = "Date";
                MySerie.YField = new string[1];
                MySerie.YField[0] = "Value";
                MySerie.Title = "Test";
    
    
                MySerie.MarkerConfig = new SpriteAttributes();
                MySerie.MarkerConfig.Fill = "#00ff00";
                MySerie.MarkerConfig.Stroke = "#00ff00";
                MySerie.MarkerConfig.Type = SpriteType.Circle;
                MySerie.MarkerConfig.Size = 3;
                MySerie.MarkerConfig.Radius = 3;
    
                MySerie.Style = new SpriteAttributes();
                MySerie.Style.Fill = "#00ff00";
                MySerie.Style.Stroke = "#00ff00";
                MySerie.Style.StrokeWidth = 0;
    
    
                MyChart.StoreID = "stoCharts";
                MyChart.Animate = true;
    
                MyChart.Legend = true;
                MyChart.Axes.Add(AxesX);
                MyChart.Axes.Add(AxesY);
    
             
               return MyChart;
           }
    
         private Panel BuildPanel()
         {
             return this.X().Panel()
                             .ID("panChart")
                             .Title("Chart")
                             .Padding(5)
                             .Layout("Fit")
                             .Add(BuildChart());
         }
    
        </script>
                
    <!DOCTYPE html protected "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
        <head id="Head1" runat="server">
            <title>Test Chart into panel</title>
            
            <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
               
        </head>
        
        <body>
            <form id="form1" runat="server">
                 <ext:ResourceManager ID="ResourceManager1" runat="server" RethrowAjaxExceptions="True">
    
                </ext:ResourceManager>
                <%-- Data stores--%>
                <ext:Store ID="stoCharts" runat="server" AutoLoad="True">
                    <Reader>
                        <ext:ArrayReader />
                    </Reader>
                    <Model>
                        <ext:Model ID="Model2" runat="server">
                            <Fields>
                                <ext:ModelField Name="Date"  />
                                <ext:ModelField Name="Value" />
                            </Fields>
                        </ext:Model>
                    </Model>        
                </ext:Store>
    
               
                <ext:Desktop 
                    ID="MyDesktop" 
                    runat="server">
                    
                    <Modules>
                        <%-- Dashboard window--%>
                        <ext:DesktopModule ModuleID="Dashboard">
                            <Window>
                                <ext:Window ID="wndDashoard" 
                                    runat="server" 
                                    Icon="Help"             
                                    Width="1000"
                                    Height="600"
                                    Layout="Fit" 
                                    Hidden="True" 
                                    ExpandOnShow="True" 
                                    MinHeight="100" 
                                    MinWidth="100" 
                                    Maximizable="True" 
                                    Minimizable="True"
                                    Resizable="True" 
                                    Title="Dashboard" 
                                    Modal="False" Draggable="True">                        
                                </ext:Window>
                            </Window>
                        </ext:DesktopModule>
                    </Modules>            
                    <StartMenu Height="300" Title="Start Here" runat="server" HideTools="True">             
                        <MenuItems>
                            <ext:MenuItem Text="Launch Window">
                                <Listeners>
                                    <Click Handler="#{MyDesktop}.getModule('Dashboard').createWindow();"></Click>
                                </Listeners>
                                <DirectEvents>
                                    <Click OnEvent="TestCharts"></Click>
                                </DirectEvents>
                            </ext:MenuItem>
                       </MenuItems>
                    </StartMenu>
                 </ext:Desktop>
    
             </form>
        </body>
    
    </html>
    C# code seems not to be good :

    Window myWindow = MyDesktop.Modules('Dashboard').Window(0);
    says :
    Ext.Net.Desktop.Modules couldn't be called and couldn' t be used as a method.
    (translate from french, not sure it be the right translation in english)

    Same code in VB code behind give no errors, I get the window, but panels are not added to the window that open itself but empty.

    How to achieve that.
    Last edited by Daniil; May 23, 2012 at 1:04 PM. Reason: [CLOSED]
  2. #2
    C# uses [] for indexing, but VB - ().

    Also it will require to case AbstractWindow to Window explicitly.

    One more thing - you should use the Render method during DirectEvent to render controls.

    Example
    protected void TestCharts(object sender, EventArgs e)
    {
        Window myWindow = MyDesktop.Modules["Dashboard"].Window[0] as Window;
        BuildPanel().Render(myWindow);
    }
    In addition, I think you should wrap Page_Load code in
    if (!X.IsAjaxRequest)
    to avoid store re-binding on each ajax request.
  3. #3
    Works fine, thank you.

Similar Threads

  1. [CLOSED] Need to create DirectEVent for dynamically added fileupload
    By wisdomchuck in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 21, 2012, 3:12 PM
  2. Create new window dynamically on button click from another window
    By softlabsgroup.support in forum 1.x Help
    Replies: 6
    Last Post: May 01, 2012, 9:26 AM
  3. Replies: 2
    Last Post: Oct 11, 2011, 1:15 PM
  4. How to create DesktopModule object
    By jack_jj in forum 1.x Help
    Replies: 0
    Last Post: Dec 08, 2008, 8:24 AM
  5. [CLOSED] How to create array object in codebehind
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 09, 2008, 6:20 AM

Posting Permissions