"Magnify" a panel inside a window : how to ?

  1. #1

    "Magnify" a panel inside a window : how to ?

    Hi,
    i have a web app with several panels. Some have grids, others have graphs, text or whatever. On small screens some panels are small, and this is normal. However, i would like to let the user "magnify" any panel and show it in a full screen window.
    here is a simplified exampe; code (i do this from code behind) :

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    
    <!DOCTYPE html>
    <script runat="server">
        public List<object> Data
        {
            get
            {
                string[] produits = new string[] 
                { 
                    "3m Co",
                    "Alcoa Inc",
                    "Altria Group Inc",
                    "American Express Company",
                    "American International Group, Inc.",
                    "AT&T Inc.",
                    "Boeing Co.",
                    "Caterpillar Inc.",
                    "Citigroup, Inc.",
                    "E.I. du Pont de Nemours and Company",
                    "Exxon Mobil Corp"
                };
    
                Random rand = new Random();
                List<object> data = new List<object>(produits.Length);
    
                for (int i = 0; i < produits.Length; i++)
                {
                    data.Add(new
                    {
                        produit = produits[i],
                        CAHT = rand.Next(10000) / 100d,
                        NbVentes = rand.Next(10000) / 100d,
                        NbUnites = rand.Next(10000) / 100d,
                        MargeBrute = rand.Next(10000) / 100d,
                        CATTC = rand.Next(10000) / 100d,
                    });
                }
    
                return data;
            }
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    
    <body>
        <script>
    
    
            var fullscr = function (event, toolEl, panel) {
                var win = Ext.create('Ext.window.Window',
                     {
                         title: panel.title,
                         height: Ext.getBody().getViewSize().height * 0.75,
                         width: Ext.getBody().getViewSize().width * 0.75,
                        // items: [this.up().up()],
                         layout: 'fit',
                         animateTarget: toolEl,
                         modal: true,
                         closeAction: 'destroy',
                     }
             );
                Ext.apply(win, { items: panel.up().items });
                win.show();
            };
    
        </script>
        <form id="form1" runat="server">
    
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Panel runat="server" Title="My test" Header="true" Collapsible="true" Height="600" Width="400">
                <Tools>
                    <ext:Tool  Type ="Plus" Fn = "fullscr" ID="ctl33"/>
                </Tools>
                <Bin>
                    <ext:Store
                        ID="CompanyStore"
                        runat="server"
                        Data="<%# Data %>"
                        AutoDataBind="true">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="produit" Mapping="produit" />
                                    <ext:ModelField Name="CAHT" Mapping="CAHT" Type="Float" />
                                    <ext:ModelField Name="NbVentes" Mapping="NbVentes" Type="Float" />
                                    <ext:ModelField Name="NbUnites" Mapping="NbUnites" Type="Float" />
                                    <ext:ModelField Name="MargeBrute" Mapping="MargeBrute" Type="Float" />
                                    <ext:ModelField Name="CATTC" Mapping="CATTC" Type="Float" />
                                    <ext:ModelField Name="cumul" Type="Int" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Bin>
                <Items>
                    <ext:GridPanel
                        Layout="FitLayout"
                        ID="CompanyGrid"
                        runat="server"
                        Flex="1"
                        Header="false"
                        StoreID="CompanyStore">
                        <ColumnModel>
                            <Columns>
                                <ext:Column
                                    ID="Company"
                                    runat="server"
                                    Text="Produit"
                                    Flex="1"
                                    DataIndex="produit" />
                                <ext:Column ID="Column1"
                                    runat="server"
                                    Text="CAHT"
                                    DataIndex="CAHT"
                                    flex="1"
                                    Align="Right">
                                    <Renderer Format="UsMoney" />
                                </ext:Column>
                                <ext:Column ID="Column2"
                                    runat="server"
                                    Text="NbVentes"
                                    DataIndex="NbVentes"
                                    flex="1"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column3"
                                    runat="server"
                                    Text="NbUnites"
                                    flex="1"
                                    DataIndex="NbUnites"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column4"
                                    runat="server"
                                    Text="MargeBrute"
                                    flex="1"
                                    DataIndex="MargeBrute"
                                    Align="Right">
             
                                </ext:Column>
                                <ext:Column ID="Column5"
                                    runat="server"
                                    Text="CATTC"
                                   flex="1"
                                    DataIndex="CATTC"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column6"
                                    runat="server"
                                    Text="cumul"
                                  flex="1"
                                    DataIndex="cumul"
                                    Align="Right">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </form>
    </body>
    </html>
    I have several issues with this code:

    1. when we click the "plus" button, the content of the panel is now inside the window : OK... but it is gone from the window : is there anyway we can crete a "clone" of the object so that a copy is inside the window, but original content does not disapear from the original panel ?
    2. other issue : the demo grid should fit all the window (fitlayout) : why doesn't it ?

    Here are screenshots for better understanding :

    Click image for larger version. 

Name:	initial.PNG 
Views:	41 
Size:	53.9 KB 
ID:	7811
    Click image for larger version. 

Name:	window.PNG 
Views:	36 
Size:	70.9 KB 
ID:	7821
    Click image for larger version. 

Name:	closed window.PNG 
Views:	45 
Size:	42.2 KB 
ID:	7831

    Thanks for your help !
    Last edited by brunweb; Mar 06, 2014 at 5:05 PM.
  2. #2
    Hi @brunweb,

    There is no a "clone" method. Moreover, it might be very complicated to implement it in your scenario. I would recommend you not to do that.

    You can return the components back to the Panel on closing of the Window.

    Here is an updated sample. The layout issue is also fixed.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        public List<object> Data
        {
            get
            {
                string[] produits = new string[] 
                { 
                    "3m Co",
                    "Alcoa Inc",
                    "Altria Group Inc",
                    "American Express Company",
                    "American International Group, Inc.",
                    "AT&T Inc.",
                    "Boeing Co.",
                    "Caterpillar Inc.",
                    "Citigroup, Inc.",
                    "E.I. du Pont de Nemours and Company",
                    "Exxon Mobil Corp"
                };
    
                Random rand = new Random();
                List<object> data = new List<object>(produits.Length);
    
                for (int i = 0; i < produits.Length; i++)
                {
                    data.Add(new
                    {
                        produit = produits[i],
                        CAHT = rand.Next(10000) / 100d,
                        NbVentes = rand.Next(10000) / 100d,
                        NbUnites = rand.Next(10000) / 100d,
                        MargeBrute = rand.Next(10000) / 100d,
                        CATTC = rand.Next(10000) / 100d,
                    });
                }
    
                return data;
            }
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var fullscr = function (event, toolEl, panel) {
                var win = Ext.create('Ext.window.Window', {
                    title: panel.title,
                    height: Ext.getBody().getViewSize().height * 0.75,
                    width: Ext.getBody().getViewSize().width * 0.75,
                    items: panel.up().items.getAt(0),
                    layout: 'fit',
                    animateTarget: toolEl,
                    modal: true,
                    closeAction: 'destroy',
                    listeners: {
                        beforedestroy: function () {
                            App.Panel1.add(this.items.getAt(0));
                        }
                    }
                }).show();
            };
    
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Panel 
                ID="Panel1" 
                runat="server" 
                Title="My test" 
                Height="600" 
                Width="400"
                Layout="FitLayout">
                <Tools>
                    <ext:Tool Type="Plus" Fn="fullscr" />
                </Tools>
                <Bin>
                    <ext:Store
                        ID="CompanyStore"
                        runat="server"
                        Data="<%# Data %>"
                        AutoDataBind="true">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="produit" />
                                    <ext:ModelField Name="CAHT" Type="Float" />
                                    <ext:ModelField Name="NbVentes" Type="Float" />
                                    <ext:ModelField Name="NbUnites" Type="Float" />
                                    <ext:ModelField Name="MargeBrute" Type="Float" />
                                    <ext:ModelField Name="CATTC" Type="Float" />
                                    <ext:ModelField Name="cumul" Type="Int" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Bin>
                <Items>
                    <ext:GridPanel
                        ID="CompanyGrid"
                        runat="server"
                        StoreID="CompanyStore">
                        <ColumnModel>
                            <Columns>
                                <ext:Column
                                    runat="server"
                                    Text="Produit"
                                    Flex="1"
                                    DataIndex="produit" />
                                <ext:Column 
                                    runat="server"
                                    Text="CAHT"
                                    DataIndex="CAHT"
                                    Flex="1"
                                    Align="Right">
                                    <Renderer Format="UsMoney" />
                                </ext:Column>
                                <ext:Column 
                                    runat="server"
                                    Text="NbVentes"
                                    DataIndex="NbVentes"
                                    Flex="1"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column 
                                    runat="server"
                                    Text="NbUnites"
                                    Flex="1"
                                    DataIndex="NbUnites"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column
                                    runat="server"
                                    Text="MargeBrute"
                                    Flex="1"
                                    DataIndex="MargeBrute"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column
                                    runat="server"
                                    Text="CATTC"
                                    Flex="1"
                                    DataIndex="CATTC"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column
                                    runat="server"
                                    Text="cumul"
                                    Flex="1"
                                    DataIndex="cumul"
                                    Align="Right">
                                </ext:Column>
                            </Columns>
                        </ColumnModel>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil !
    Thank you for your answer !
    It works in the example, but i cannot really use it because of this :
    listeners: {
                        beforedestroy: function () {
                            App.Panel1.add(this.items.getAt(0));
                        }
                    }
    "Panel1" is the id in the example; but this has to be dynamic (should be taken from :
    var fullscr = function (event, toolEl, panel)
    )

    Anyway, i should have thought of adding a listener to the window : thanks for this idea !

    I tried a few things without success : i wonder why this does not work in the listener :
    panel.items.add(this.items.getAt(0));
    Any idea ?
    Thks in advance !
    Last edited by Daniil; Mar 11, 2014 at 4:18 AM. Reason: Please use [CODE] tags
  4. #4
    Quote Originally Posted by brunweb View Post
    I tried a few things without success : i wonder why this does not work in the listener :
    panel.items.add(this.items.getAt(0));
    The "panel" argument is actually the Panel's header component, not a Panel itself.

    This appears to be working.
    listeners: {
        beforedestroy: function () {
            panel.ownerCt.add(this.items.getAt(0));
        }
    }
  5. #5
    Hi Daniil,
    thanks for your answer : the example now works.
    This is only an example i created for the forum, but in real scenario, i still have an issue : in fact, i would like this feature for any Ext.Net.AbstractPanel : means the tool can be on a panel, but could aslo be directly on a gridpanel : this case does not work.
    I'll try to provide an example soon.

    Thanks again
  6. #6
    Quote Originally Posted by brunweb View Post
    I'll try to provide an example soon.
    Yes, please provide a test case.
  7. #7
    Hi Danill !

    Below is a demo showing some working sampel... and some not.
    First Panel (green): it is a panel that contains a gridPanel.
    Second panel (red) : gridpanel
    third : a panel containing a chart. (very hard to read, just to illustrate why this feature might be nice).


    I used the new "UI" feature to show more easelly how "panel" are nested.
    <%@ Page Language="C#" %>
    
    <script runat="server">
        public List<object> Data
        {
            get
            {
                string[] comp = new string[]
                {
                    "3m Co",
                    "Alcoa Inc",
                    "Altria Group Inc",
                    "American Express Company",
                    "American International Group, Inc.",
                    "AT&T Inc.",
                    "Boeing Co.",
                    "Caterpillar Inc.",
                    "Citigroup, Inc.",
                    "E.I. du Pont de Nemours and Company",
                    "Exxon Mobil Corp"
                };
    
                Random rand = new Random();
                List<object> data = new List<object>(comp.Length);
    
                for (int i = 0; i < comp.Length; i++)
                {
                    data.Add(new
                    {
                        company = comp[i],
                        A = rand.Next(10000) / 100d,
                        B = rand.Next(10000) / 100d,
                        C = rand.Next(10000) / 100d,
                        D = rand.Next(10000) / 100d,
                        E = rand.Next(10000) / 100d,
                    });
                }
    
                return data;
            }
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var fullscr = function (event, toolEl, panel) {
                var win = Ext.create('Ext.window.Window', {
                    title: panel.title,
                    height: Ext.getBody().getViewSize().height * 0.75,
                    width: Ext.getBody().getViewSize().width * 0.75,
                    layout: 'fit',
                    animateTarget: toolEl,
                    modal: true,
                    closeAction: 'destroy'
    
                });
    
    
                if (panel.ownerCt.getXType() == 'panel') {
                    win.add(panel.ownerCt.items.getAt(0));
                    win.on('beforedestroy', function () { panel.ownerCt.add(this.items.getAt(0)); });
    
                }
                else if (panel.ownerCt.getXType() == 'grid') {
                    alert('Crashes Here ...');
                    win.add(panel.ownerCt.items.getAt(0));
                    win.listeners= {
                        beforedestroy: function () {
                            panel.ownerCt.add(this.items.getAt(0));
              
                        }
                    }
                };
                win.show();
            };
    
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Container runat="server" Layout="VBoxLayout">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" DefaultMargins="5 5 5 5" />
                </LayoutConfig>
    
                <Bin>
                    <ext:Store
                        ID="CompanyStore"
                        runat="server"
                        Data="<%# Data %>"
                        AutoDataBind="true">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="company" />
                                    <ext:ModelField Name="A" Type="Float" />
                                    <ext:ModelField Name="B" Type="Float" />
                                    <ext:ModelField Name="C" Type="Float" />
                                    <ext:ModelField Name="D" Type="Float" />
                                    <ext:ModelField Name="E" Type="Float" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Bin>
                <Items>
                    <ext:Panel 
                        ID="containerpanel" 
                        runat="server"
                        Header="true" 
                        UI="Success" 
                        Layout="FitLayout"
                        Title="This panel contains a grid panel : the 'plus button' will do what i thought the grid panel header would do">
                        <Tools>
                            <ext:Tool Type="Plus" Fn="fullscr" />
                            <ext:Tool Type="Unpin" Handler="GridPanel1.header = !GridPanel1.header;" />
                        </Tools>
                        <Items>
                            <ext:GridPanel
                                ID="GridPanel1"
                                runat="server"
                                StoreID="CompanyStore"
                                Title="GridPanel : Working Example" 
                                Layout="FitLayout"
                                UI="Warning" Header ="false">
    
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column ID="Column7"
                                            runat="server"
                                            Text="Company"
                                            Flex="1"
                                            DataIndex="company" />
                                        <ext:Column ID="Column8"
                                            runat="server"
                                            Text="A"
                                            DataIndex="A"
                                            Flex="1"
                                            Align="Right">
                                            <Renderer Format="UsMoney" />
                                        </ext:Column>
                                        <ext:Column ID="Column9"
                                            runat="server"
                                            Text="B"
                                            DataIndex="B"
                                            Flex="1"
                                            Align="Right">
                                        </ext:Column>
                                        <ext:Column ID="Column10"
                                            runat="server"
                                            Text="C"
                                            Flex="1"
                                            DataIndex="C"
                                            Align="Right">
                                        </ext:Column>
                                        <ext:Column ID="Column11"
                                            runat="server"
                                            Text="D"
                                            Flex="1"
                                            DataIndex="D"
                                            Align="Right">
                                        </ext:Column>
                                        <ext:Column ID="Column12"
                                            runat="server"
                                            Text="E"
                                            Flex="1"
                                            DataIndex="E"
                                            Align="Right">
                                        </ext:Column>
    
                                    </Columns>
                                </ColumnModel>
                                <Tools>
                                    <ext:Tool Type="Plus" Fn="fullscr" />
                                </Tools>
                            </ext:GridPanel>
    
                        </Items>
    
                    </ext:Panel>
                    <ext:GridPanel
                        ID="CompanyGrid"
                        runat="server"
                        StoreID="CompanyStore"
                        Title="GridPanel : not working Example"
                        UI="Danger"
                       >
    
                        <ColumnModel>
                            <Columns>
                                <ext:Column ID="Column1"
                                    runat="server"
                                    Text="Company"
                                    Flex="1"
                                    DataIndex="company" />
                                <ext:Column ID="Column2"
                                    runat="server"
                                    Text="A"
                                    DataIndex="A"
                                    Flex="1"
                                    Align="Right">
                                    <Renderer Format="UsMoney" />
                                </ext:Column>
                                <ext:Column ID="Column3"
                                    runat="server"
                                    Text="B"
                                    DataIndex="B"
                                    Flex="1"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column4"
                                    runat="server"
                                    Text="C"
                                    Flex="1"
                                    DataIndex="C"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column5"
                                    runat="server"
                                    Text="D"
                                    Flex="1"
                                    DataIndex="D"
                                    Align="Right">
                                </ext:Column>
                                <ext:Column ID="Column6"
                                    runat="server"
                                    Text="E"
                                    Flex="1"
                                    DataIndex="E"
                                    Align="Right">
                                </ext:Column>
    
                            </Columns>
                        </ColumnModel>
                        <Tools>
                            <ext:Tool Type="Plus" Fn="fullscr" />
                        </Tools>
                    </ext:GridPanel>
                    <ext:Panel
                        ID="Panel1"
                        runat="server"
                        Title="Panel example"
                        Height="200"
                        Layout="FitLayout"
                        UI="Primary">
                        <Tools>
                            <ext:Tool Type="Plus" Fn="fullscr" />
                        </Tools>
                        <Items>
                            <ext:Chart ID="Chart1"
                                runat="server"
                                Animate="true"
                                Shadow="true"
                                InsetPadding="60"
                                Theme="Base:gradients"
                                StoreID="CompanyStore">
                                <Store>
                                </Store>
                                <Series>
                                    <ext:PieSeries
                                        AngleField="A"
                                        ShowInLegend="true"
                                        Donut="0"
                                        Highlight="true"
                                        HighlightSegmentMargin="20">
                                        <Label Field="company" Display="Rotate" Contrast="true" Font="18px Arial" />
                                    </ext:PieSeries>
                                </Series>
                            </ext:Chart>
                        </Items>
    
                    </ext:Panel>
    
                </Items>
            </ext:Container>
    
        </form>
    </body>
    </html>
    Click image for larger version. 

Name:	Capture.png 
Views:	38 
Size:	65.2 KB 
ID:	8031
    Second example does not work as I expect it to. I understand what the problem is : this grid panel is not itself inside another container (i mean is not alone inside another). What i would like to do in that case is be able to get the "grid only" to give same illusoin as in the first exampe (green one).

    Of course i could use an hack and put all my gridpanels inside panels with header hidden (like first example) but i am sure there must be another cleaner way to do it.

    BTW : on the last panel, with UI="Primary" , look how the plus tool renders : looks like image is not clean.

    Thanks.
  8. #8
    Thank you for a test case.

    Quote Originally Posted by brunweb View Post
    Of course i could use an hack and put all my gridpanels inside panels with header hidden (like first example) but i am sure there must be another cleaner way to do it.
    I don't see a good solution without wrapping a GridPanel in an additional Panel. Moreover, I think it is the best solution in your scenario. Though, you are good that you tried to avoid an additional Panel. Less components, better performance.

    Quote Originally Posted by brunweb View Post
    BTW : on the last panel, with UI="Primary" , look how the plus tool renders : looks like image is not clean.
    Thank you for the report. Created an Issue:
    https://github.com/extnet/Ext.NET/issues/450
  9. #9
    Hi Daniil,
    Thank you for your answer, it is what I thought.
    Have a nice day!

Similar Threads

  1. Replies: 14
    Last Post: Apr 27, 2016, 12:49 AM
  2. Replies: 0
    Last Post: Nov 15, 2013, 9:32 AM
  3. [CLOSED] Problem to use property "Maximized" from "Window"
    By avante in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 22, 2013, 12:47 AM
  4. [CLOSED] How does "MaskCls" work for "AutoLoad" mask in panel control
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 19, 2012, 12:09 PM
  5. Replies: 5
    Last Post: May 02, 2012, 5:37 PM

Tags for this Thread

Posting Permissions