[CLOSED] Reset GridPanel columns to initial state

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Reset GridPanel columns to initial state

    After resizing, moving, sorting, etc, is there a way to reset a GridPanel's columns to the way they were when the page was initially loaded?
    Last edited by Daniil; Jul 25, 2011 at 8:57 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, there is no such functionality to revert all changes.

    I can suggest you to isolate a grid into a user control and re-render it from server side when needed.
  3. #3
    Do you have an example of rerendering a user control from the server side?
  4. #4
    Well, it needs to re-render a grid.

    Here is the simple example.

    Example Page

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            MyGrid uc = (MyGrid)this.LoadControl("TestUC.ascx");
            uc.ID = "MyGrid1";
            this.Panel1.ContentControls.Add(uc);
    
            if (!X.IsAjaxRequest)
            {
                uc.DataBind();
            }
        }
    
        protected void Reset(object sender, DirectEventArgs e)
        {
            MyGrid uc = (MyGrid)this.FindControl("MyGrid1");
            uc.Reset();
        }
    </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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Panel ID="Panel1" runat="server" Width="400" Height="300" />
            <ext:Button runat="server" Text="Reset" OnDirectClick="Reset" />
        </form>
    </body>
    </html>
    Example User Control

    <%@ Control Language="C#" ClassName="MyGrid" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void DataBind()
        {
            Store store = this.GridPanel1.GetStore();
            store.DataSource = new object[] 
            { 
                new object[] { "test11", "test12", "test13" },
                new object[] { "test12", "test22", "test23" },
                new object[] { "test13", "test32", "test33" }
            };
            store.DataBind();
        }
    
        public void Reset()
        {
            this.DataBind();
            this.GridPanel1.Render();
        }
    </script>
    
    <ext:FitLayout runat="server">
        <Items>
            <ext:GridPanel ID="GridPanel1" runat="server" Stateful="false">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="test1" />
                                    <ext:RecordField Name="test2" />
                                    <ext:RecordField Name="test3" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Test1" DataIndex="test1" />
                        <ext:Column Header="Test2" DataIndex="test2" />
                        <ext:Column Header="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>
  5. #5
    Ok. That example appears to do what I'm looking for, but I have a few questions so I can better understand what's going on.

    Why is it necessary to isolate the grid into a user control? Couldn't I just call grid.render() in the page it's in currently?

    This is probably a dumb question but how does it know what the initial state of the grid is? What exactly is happening when .render() is called?
  6. #6
    Quote Originally Posted by jmcantrell View Post
    Why is it necessary to isolate the grid into a user control? Couldn't I just call grid.render() in the page it's in currently
    Well, you are right, a user control is not required.

    Quote Originally Posted by jmcantrell View Post
    how does it know what the initial state of the grid is? What exactly is happening when .render() is called?
    It just destroy a grid and render a new one.

Similar Threads

  1. [CLOSED] GridPanel - state for columns
    By PatrikG in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 13, 2012, 1:48 PM
  2. [CLOSED] [1.0] GridPanel's reconfigure reset columns' filter property
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 21, 2011, 10:39 AM
  3. Accordion Layout initial state
    By dcrysler in forum 1.x Help
    Replies: 1
    Last Post: Jul 15, 2011, 8:53 PM
  4. Replies: 0
    Last Post: May 09, 2011, 9:58 AM
  5. Replies: 3
    Last Post: Dec 03, 2010, 4:27 PM

Tags for this Thread

Posting Permissions