May 16, 2011, 9:21 PM
[CLOSED] Store not populated/updated if I do a clear/empty data just before filling the data
Hey again!
I have noticed a problem. In moste pages I have data to be filled in forms and Controls. Usually I also create a method to clear all data, ie clear all stores, clear all comboBoxes, TextFields etc etc.
Normally I want to do a Clear before populating data. This ensures that all fields are empty, and whatever data I populate thereafter will be added to an empty scene so to speak.
What I discovered was that if I first execute such a Clear-method, and then populate the data, the data will not be populated at all. If I do not execute the Clear first, then the data is populated.
I dont get why.
Heres a runnable example:
I have noticed a problem. In moste pages I have data to be filled in forms and Controls. Usually I also create a method to clear all data, ie clear all stores, clear all comboBoxes, TextFields etc etc.
Normally I want to do a Clear before populating data. This ensures that all fields are empty, and whatever data I populate thereafter will be added to an empty scene so to speak.
What I discovered was that if I first execute such a Clear-method, and then populate the data, the data will not be populated at all. If I do not execute the Clear first, then the data is populated.
I dont get why.
Heres a runnable example:
<%@ 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)
{
if (!X.IsAjaxRequest)
{
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(); // If this is not commented out, then NewDataX will not be populated. If I comment this out, it works
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" AutoLoad="true">
<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 18, 2011 at 6:46 PM.
Reason: [CLOSED]