Sep 23, 2011, 7:40 AM
dynamic creating of GridPanel Column and binding with dataset
Hi ,
I have created a functions which create record set in store and another function which creates a Columns in Grid panel, but when i run the code only columns are added to Gridpanel and there is no data. Please helo thanks in advance
See following code
-- this one for binding store
I have created a functions which create record set in store and another function which creates a Columns in Grid panel, but when i run the code only columns are added to Gridpanel and there is no data. Please helo thanks in advance
See following code
-- this one for binding store
public string BuildStore(params string[] fields)
{
JsonReader ar = new JsonReader();
foreach (string field in fields)
{
RecordField rf = new RecordField(field);
ar.Fields.Add(rf);
}
Store1.Reader.Add(ar);
Store1.DataSource = fn.bindgrid(hdquery.Value, constr);
Store1.DataBind();
BuildGridPanel(fn.bindgrid(hdquery.Value, constr));
return "Sucess";
}
This one is for creating gridpanel
private GridPanel BuildGridPanel(DataSet ds)
{
FormLayout schemaFL = new FormLayout();
Ext.Net.Anchor a = new Ext.Net.Anchor();
a.Horizontal = "95%";
GridPanel grid = new GridPanel();
grid.ID = "Grid1";
grid.Width = Unit.Pixel(300);
grid.Height = Unit.Pixel(300);
grid.StoreID = Store1.ID;
for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
{
Ext.Net.Column col = new Ext.Net.Column();
col.ColumnID = ds.Tables[0].Columns[i].ToString();
col.Header = ds.Tables[0].Columns[i].ToString();
col.DataIndex = ds.Tables[0].Columns[i].ToString();
col.Sortable = true;
grid.ColumnModel.Columns.Add(col);
}
a.Items.Add(grid);
schemaFL.Anchors.Add(a);
Panel1.Items.Add(schemaFL);
return grid;
}
Last edited by Daniil; Sep 23, 2011 at 11:48 AM.
Reason: Please use [CODE] tags