[CLOSED] Why can't I re-populate Store and update GridPanel from this DirectMethod?

  1. #1

    [CLOSED] Why can't I re-populate Store and update GridPanel from this DirectMethod?

    I was about to post another question, then I ran into trouble with this simple code.

    I have updated many many Store by now, and thought this was easy. But for some reason I cannot re-populate the Store and thus the GridPanel in the example below.

    It is populated once, then never again.

    So if I let the code in Page_Load be, it is populated with "blaX". Then, if I press the button I was hoping that the data should be replaced by "NewDataX", but it is not.

    If I remove the code from Page_Load, and then press the button the Store and GridPanel is filled with "NewDataX".

    What am I missing?



    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Register TagPrefix="CP" TagName="MyUserControl" Src="MyUserControl.ascx" %>
    
    <script runat="server">
        
    </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 id="Head1" runat="server">
        <title>Ext.NET Examples</title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                List<object> data = new List<object>();
                data.Add(new object[] { "bla1", "bla2", "bla3" });
                Store1.DataSource = data;
                Store1.DataBind();
            }
    
            public void ClearData()
            {
                List<object> data = new List<object>();
                Store1.DataSource = data;
                Store1.DataBind();
            }
            
            [DirectMethod]
            public void FillData()
            {
               // ClearData();
    
                List<object> data = new List<object>();
                data.Add(new object[] { "NewData1", "NewData2", "NewData3" });
                Store1.DataSource = data;
                Store1.DataBind();
            }
        
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
                  
             <ext:Button runat="server" ID="btnTest" Text="test">
                <Listeners>
                    <Click Handler="Ext.net.DirectMethods.FillData();" />
                </Listeners>
             </ext:Button>
             <ext:GridPanel ID="GridPanel2" runat="server" StripeRows="true" Header="true" Border="true" Layout="Fit" AutoHeight="true">
                <Store>
                    <ext:Store runat="server" ID="Store1">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="Data1"></ext:RecordField>
                                    <ext:RecordField Name="Data2"></ext:RecordField>
                                    <ext:RecordField Name="Data3"></ext:RecordField>
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel2" runat="server" >
                    <Columns>
                        <ext:Column DataIndex="Data1" Header="d1" />
                        <ext:Column DataIndex="Data2" Header="d2" />
                        <ext:Column DataIndex="Data3" Header="d3"  />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by geoffrey.mcgill; May 16, 2011 at 9:33 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Thanks for the excellent code sample.

    You just need to wrap the code in the Page_Load with an !X.IsAjaxRequest.

    Example

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            List<object> data = new List<object>();
            data.Add(new object[] { "bla1", "bla2", "bla3" });
            Store1.DataSource = data;
            Store1.DataBind();
        }
    }
    Geoffrey McGill
    Founder
  3. #3
    Of course! Me so stupid sometimes =)

    Good, then I can post the question I wanted to ask =)

Similar Threads

  1. Replies: 12
    Last Post: Aug 09, 2013, 2:25 PM
  2. Replies: 1
    Last Post: Jun 12, 2012, 10:34 AM
  3. [CLOSED] loop though gridpanel and update store
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 03, 2011, 8:11 AM
  4. Update GridPanel With Store Values
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 0
    Last Post: Oct 20, 2010, 2:42 PM
  5. [CLOSED] Update GridPanel from Store
    By danielg in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 12, 2009, 11:44 AM

Tags for this Thread

Posting Permissions