[OPEN] [#96] ColumnHeaderGroup Hideable columns

  1. #1

    [OPEN] [#96] ColumnHeaderGroup Hideable columns

    [SENCHA bug ticket is EXTJSIV-6597]
    [4.1.1 rc2] Columns Group with non hidable column

    I used the Group Header Column example to detail this issue.
    Not sure if you would consider this a bug or a feature or something else.

    I have a ColumnHeaderGroup named "Stock Price" that has 3 columns under it "Price", "Change" and "Change %". I decided that the "Price" column is not Hideable. So here is what I expected:

    1) I can hide the "Change" or "Change %" column and the "Price" column is always showing.
    2) I can hide the ColumnHeaderGroup "Stock Price" and everything is hidden.
    3) When everything is hidden, I can unhide the "Change" column and the "Price" column will also show up. Broken

    My assumption was that if any columns under the "Stock Price" column is shown the non-hideable columns ("Price") should also be shown.

    I have not brought my work computer up to the latest revision, I will do that tomorrow.
    Your thoughts ...

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
            }
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Grouped Header Example - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />    
        
        <style type="text/css">
            /* style rows on mouseover */
            .x-grid-row-over .x-grid-cell-inner {
                font-weight: bold;
            }
        </style>
    
        <script type="text/javascript">
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value);
            };
    
            var pctChange = function (value) {
                return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <h1>Grouped Header Example</h1>
        <p>This example shows how to create a grid with column headers which are nested within category headers.</p>
        <p>Category headers do not reference Model fields via a <code>dataIndex</code>, rather they contain
        child header definitions (which may themselves either contain a <code>dataIndex</code> or more levels of headers).</p>
        
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            Title="Grouped Header Grid" 
            Width="600" 
            ColumnLines="true"
            Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="company" />
                                <ext:ModelField Name="price" Type="Float" />
                                <ext:ModelField Name="change" Type="Float" />
                                <ext:ModelField Name="pctChange" Type="Float" />
                                <ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column runat="server" Text="Company" DataIndex="company" Flex="1" Sortable="false" />
    
                    <ext:Column runat="server" Text="Stock Price">
                        <Columns>
                            <ext:Column runat="server" Text="Price" DataIndex="price" Width="75" Sortable="true" Hideable="false">                  
                                <Renderer Format="UsMoney" />
                            </ext:Column>
                            <ext:Column runat="server" Text="Change" DataIndex="change" Width="75" Sortable="true">
                                <Renderer Fn="change" />
                            </ext:Column>
                            <ext:Column runat="server" Text="Change %" DataIndex="pctChange" Width="75" Sortable="true">
                                <Renderer Fn="pctChange" />
                            </ext:Column>
                        </Columns>
                    </ext:Column>                
                    
                    <ext:DateColumn runat="server" Text="Last Updated" DataIndex="lastChange" Width="85" Sortable="true" Format="dd/MM/yyyy" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html
    Last edited by cwolcott; Mar 07, 2013 at 1:41 PM.
  2. #2
    Hi,

    I would rather consider it a bug as well. But, maybe, it is by design. I think many users can expect the non hidable column should not appear in that case.

    I have reported it to Sencha.
    http://www.sencha.com/forum/showthre...528#post837528

    Lets wait what they will answer.

    Anyways, it is easy to implement the behavior you need. Please see the Group column Show listener.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//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 runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server">
            <Store>
                <ext:Store runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="test1" />
                                <ext:ModelField Name="test2" />
                                <ext:ModelField Name="test3" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column runat="server" Text="Group">
                        <Columns>
                            <ext:Column 
                                ID="Column1" 
                                runat="server" 
                                Text="Test1" 
                                DataIndex="test1" 
                                Hideable="false" />
                            <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                            <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                        </Columns>
                        <Listeners>
                            <Show Handler="App.Column1.show();" />
                        </Listeners>
                    </ext:Column>
                    <ext:Column runat="server" Text="Just to allow to hide the Group column" Width="200" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>
  3. #3
    I was able to get your sample to work, but for my application the code:

    <Listeners>
       <Show Handler="App.Column1.show();" />
    </Listeners>
    caused the error "Cannot call method 'show' fo undefined". So I changed it to:

    <Listeners>
       <Show Handler="#{Column1}.show();" />
    </Listeners>
    Thanks for the work around.
  4. #4
    Opened an Issue to track this defect, see:
    https://github.com/extnet/Ext.NET/issues/96
  5. #5
    Tested the sample code from above against the latest trunk. We can now hide the parent column if a child is declared hideable="false". But do we care when the parent is reshown that all of the child columns are set to hidden="false" instead of the last state.

    I think they should be set to their last state. You make the call if you want to alert Sencha or just close out the thread.
  6. #6
    Sorry, didn't follow my test case up above. It is still broken.

    1) I can hide the "Change" or "Change %" column and the "Price" column is always showing.
    2) I can hide the ColumnHeaderGroup "Stock Price" and everything is hidden.
    3) When everything is hidden, I can unhide the "Change" column and the "Price" column will also show up. Broken
  7. #7
    Thank you for the follow-up.

    The Sencha thread is still opened. I bumped it.

Similar Threads

  1. Replies: 13
    Last Post: Sep 15, 2017, 10:38 PM
  2. Replies: 7
    Last Post: Jul 02, 2012, 6:59 PM
  3. [CLOSED] ColumnHeaderGroup in a TreePanel
    By fordprefect in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 21, 2012, 3:45 PM
  4. [CLOSED] How to set a column's hideable property during a DirectEvent
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: May 23, 2011, 8:40 PM
  5. Replies: 1
    Last Post: Nov 16, 2010, 12:53 PM

Posting Permissions