May 16, 2011, 8:30 PM
[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?
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]