PDA

View Full Version : [CLOSED] simple gridpanel databind not working in v2.1



CarpFisher
Jul 20, 2012, 12:28 PM
The following code works in v2.0 but not in v2.1. Would you please take a look?


<%@ Page Language="C#" %>


<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>



<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
List<object> list = new List<object>();
list.Add(new
{
asCode = "abc",
asName = "cde",
asPerc = 10.1


});
strAssetClassOfInstrument.Data = list;
strAssetClassOfInstrument.DataBind();

}



</script>

<!DOCTYPE html>

<html>

<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />




<ext:Panel ID="pnlHost" runat="server" Layout="HBoxLayout" FocusOnToFront="true" Border="false" >
<Items>

<ext:GridPanel ID="Grid1" runat="server" Width="170" Height="155" Padding="5">
<Store>
<ext:Store ID="strAssetClassOfInstrument" runat="server">
<Model>
<ext:Model ID="Model4" runat="server">
<Fields>
<ext:ModelField Name="asCode" />
<ext:ModelField Name="asName" />
<ext:ModelField Name="asPerc" />


</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>

<ColumnModel>
<Columns>
<ext:Column ID="Column2" runat="server" Text="Name" DataIndex="asName" Flex="1"/>
<ext:Column ID="Column3" runat="server" Text="%" DataIndex="asPerc" Width="60" />
</Columns>
</ColumnModel>
</ext:GridPanel>



</Items>
</ext:Panel>


</form>
</body>
</html>

Vladimir
Jul 20, 2012, 1:31 PM
It is fixed in SVN already

If you use Data then DataBind is not required (Data will be serialized as it is, with all properties)
DataBind is used for DataSource only (DataSource is serialized according store's Model)

CarpFisher
Jul 20, 2012, 2:59 PM
Thanks it's working now!! :)

However about the DataBind() function, you still need that if you updating the Data property in DirectMethods (i.e. not within page_load function).

Daniil
Jul 20, 2012, 3:53 PM
If you need to load a data during DirectEvent/DirectMethod, please use:

store.LoadData(new object[]
{
new { test = "new" },
});