Mar 30, 2012, 5:35 AM
Store Data is not displaying in Dynamic Gridpanel
Hi, I am creating a dynamic store and dynamic gridpanel from the code behind.After that i am adding that gridpanel into a window through a code behind.But That dynamic data is not displaying in gridpanel.Only header is displaying.i am using this code.
<%@ Page Language="C#" AutoEventWireup="true">
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window
ID="Window1"
runat="server"
Title="Window1"
Icon="Application"
Height="135px"
Width="450px"
BodyStyle="background-color: #fff;"
Padding="5"
Collapsible="true"
Modal="true" Hidden="true">
</ext:Window>
<ext:Button ID="Button1" runat="server" Text="Create a grid" OnDirectClick="RenderGrid" />
</form>
</body>
</html>
protected void RenderGrid(object sender, DirectEventArgs e)
{
string s0 = "Very Good";
string s1 ="Good";
string s2 = "Poor";
string cnt0 = "2";
string cnt1 = "1";
string cnt2 = "0";
JsonReader jr = new JsonReader();
Store store = new Store()
{
ID = "Store2"
};
jr.Fields.Add(new RecordField(s0));
jr.Fields.Add(new RecordField(s1));
jr.Fields.Add(new RecordField(s2));
store.Reader.Add(jr);
store.DataSource = new List<object>()
{
new
{
s0 = cnt0,s1=cnt1,s2=cnt2
}
};
store.DataBind();
GridPanel grid = new GridPanel()
{
ID = "GridPanel2",
Width = 300,
AutoHeight = true
};
grid.Store.Add(store);
grid.ColumnModel.Columns.Add(new Column()
{
Header = s0,
DataIndex = s0,
Width = 180
});
grid.ColumnModel.Columns.Add(new Column()
{
Header = s1,
DataIndex = s1,
Width = 80
});
grid.ColumnModel.Columns.Add(new Column()
{
Header = s2,
DataIndex = s2,
Width = 80
});
grid.AddTo(this.Window1);
Window1.Show();
}
Displaying header only.Please help me.