[CLOSED] Grid State Restore - Hidden Column

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Grid State Restore - Hidden Column

    Hi,

    My grid is correctly keeping the column sort order and filtering states correctly in the cookie which is correctly restored when it is re-opened.

    However, for a column hidden manually (i.e. click on a column's dropdown menu and de-select the column so it doesn't show), the state seems to e correctly stored in the cookie (see below) but it's not restored.

    Cookie (partial):

    ....AResources%25255Ewidth%25253Dn%2525253A100%255Eo%25253Aid%25253Ds%2525253ASource%25255Ewidth%25253Dn%2525253A100%25255Ehidden%25253Db%2525253A1%255Eo%25253Aid%25253Ds%2525253ACreated.....

    Let me know what I should try.

    BTW, I'm using the latest from SVN 1.0 branch.

    Thanks,
    Eben
    Last edited by geoffrey.mcgill; Sep 17, 2010 at 6:43 PM. Reason: please use [CODE] tags, [CLOSED]
  2. #2
    Hi,

    I don't have such issue, here is my test case (hide column and refresh page)
    <%@ 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" }
                };
            }
        }
    </script>
    
    <!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>Simple Array Grid - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />    
    
        <ext:ResourcePlaceHolder runat="server" />
    
        <script type="text/javascript">
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value);
            };
    
            var pctChange = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" StateProvider="Cookie" />
        
        <h1>Simple Array Grid</h1>
        
        <ext:GridPanel 
            ID="GridPanel1"
            runat="server" 
            StripeRows="true"
            Title="Array Grid" 
            TrackMouseOver="true"
            Width="600" 
            Height="350"
            AutoExpandColumn="company">
            <Store>
                <ext:Store ID="Store1" runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="company" />
                                <ext:RecordField Name="price" Type="Float" />
                                <ext:RecordField Name="change" Type="Float" />
                                <ext:RecordField Name="pctChange" Type="Float" />
                                <ext:RecordField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
                    <ext:Column Header="Price" DataIndex="price">                  
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                    <ext:Column ColumnID="Change" Header="Change" DataIndex="change">
                        <Renderer Fn="change" />
                    </ext:Column>
                    <ext:Column Header="Change" DataIndex="pctChange">
                        <Renderer Fn="pctChange" />
                    </ext:Column>
                    <ext:DateColumn Header="Last Updated" DataIndex="lastChange" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel runat="server" SingleSelect="true" />
            </SelectionModel>
        </ext:GridPanel>          
    </body>
    </html>
    Please provide own test sample
  3. #3
    Hi,

    The example you provided does not work for what I need.

    My problem is not with hiding the column and refreshing the page.

    My test case:
    1. Hide the column
    2. Close the window containing the grid
    3. Launch the window containing the grid
    Expected: To have the column I hid still hidden.


    I have the GridPanel "Stateful" set to true and the "StateID" also set. As I mentioned earlier, keeping the grid's state works for column sorting and filtering but not for hiding.


    Thanks,
    Eben
  4. #4
    BTW, I'm using IE8 and hitting F5 brought the hidden column back on your example.


    Eben
  5. #5
    Hi,

    For me, F5 works correctly, column is still hidden (don't forget about StateProvider="Cookie")

    Please provide your test sample which demonstrates the issue
  6. #6
    I do have StateProvider="Cookie".

    Like I said, your example behaves that same way as mine on my machine.

    The fact that it works fine on yours makes it obvious there is something I'm not doing/having configured correctly.

    *** Cookie entry after hiding Company column:

    ys-GridPanel1
    o%3Acolumns%3Da%253Ao%25253Aid%25253Ds%2525253Acompany%25255Ewidth%25253Dn%2525253A358%25255Ehidden%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A1%25255Ewidth%25253Dn%2525253A100%255Eo%25253Aid%25253Ds%2525253AChange%25255Ewidth%25253Dn%2525253A100%255Eo%25253Aid%25253Dn%2525253A3%25255Ewidth%25253Dn%2525253A100%255Eo%25253Aid%25253Dn%2525253A4%25255Ewidth%25253Dn%2525253A100
    localhost/
    1088
    2193839744
    30104386
    1682792512
    30102978
    *
    The cookie looks fine where the "Company" column now has the hidden attribute.

    It feels like there is something preventing the JS code which is supposed to apply the hidden value to the column.

    Any pointers as to what could be preventing it?

    Thanks,
    Eben
    Last edited by geoffrey.mcgill; Sep 17, 2010 at 6:42 PM. Reason: please use [CODE] tags
  7. #7
    An interesting fact:

    On your example I tried hiding one by one.

    I did it left to right:
    * Company: is hidden but comes back on F5
    * Price: is hidden and STAYS hidden on F5
    * 1st Change (val = 0.02): is hidden but comes back on F5
    * 2nd Change (val = 0.03%): is hidden and STAYS hidden on F5
    * Last Updated: is hidden and STAYS hidden on F5.



    Do you get the same behavior on you side?



    Eben
  8. #8
    By inspecting the GridPanel declaration I can see a pattern where the columns that STAY hidden after F5 DO NOT have a "ColumnID" property.




    Thanks,
    Eben
  9. #9
    Looks like that's the culprit (Column->ColumnID property).

    To try it on my grid, I took the ColumnID out of one of my grid's columns and whala!, it worked!


    So now the question is: can I live without the ColumnID property without unwanted side-effects? :-)



    Eben
  10. #10
    Hi,

    If your columns is not movable (position is fixed between requests) then ColumnID is not required
    Otherwise ColumnID is required (by default, column id equals the index)
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] GridPanel Hidden Column
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Aug 27, 2012, 8:57 AM
  2. Replies: 2
    Last Post: Dec 07, 2011, 5:37 AM
  3. [CLOSED] Make an Ext.Column truly hidden
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 10, 2011, 10:53 PM
  4. [CLOSED] Restore State?
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 20, 2010, 2:58 PM
  5. [CLOSED] GridPanel Column Size Restore from Cookie
    By ecerrillos in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Oct 29, 2010, 8:05 PM

Posting Permissions