Aug 23, 2012, 11:55 PM
GridPanel.ColumnModel.Columns.Count=0 if add columns at runtime to Grid so cannot get editor field
I want to create the GridPanel that add columns with editor at the run time but. Please help!
//design
<ext:GridPanel ID="gridThietHai" runat="server" >
<Store>
<ext:Store ID="storeThietHai" runat="server">
<Reader>
<ext:JsonReader />
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="mcolThietHai">
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="smodeThietHai" SingleSelect="true">
</ext:RowSelectionModel>
</SelectionModel>
<Plugins>
<ext:RowEditor ID="editorThietHai" runat="server">
<DirectEvents>
<AfterEdit OnEvent="editorThietHai_DirectAfterEdit" />
</DirectEvents>
</ext:RowEditor>
</Plugins>
</ext:GridPanel>
//code behide
protected void Page_Load(object sender, EventArgs e)
{
if (!Ext.Net.X.IsAjaxRequest)
{
Ext.Net.Store storeMain = gridThietHai.GetStore();
Ext.Net.DataReader reader = storeMain.Reader[0];
Ext.Net.Column column;
Ext.Net.Field fld;
string colName="TEST";
reader.Fields.Add(colName);
column=new Ext.Net.Column();
column.ColumnID = colName;
column.Header = colName;
column.DataIndex = colName;
fld = new Ext.Net.TextField();
column.Editor.Add(fld);
grid.ColumnModel.Columns.Add(column);
//already do binding data for grid
}
}
protected void editorThietHai_DirectAfterEdit(object sender, Ext.Net.DirectEventArgs e)
{
Ext.Net.Field fld;
foreach (Ext.Net.Column col in gridThietHai.ColumnModel.Columns){
fld = col.Editor.Editor;
//do stm here but gridThietHai.ColumnModel.Columns.Count=0 here so I cannot get the editor of the column at runtime. Please help
}
}
Last edited by vinhpt; Aug 24, 2012 at 12:15 AM.