GridPanel.ColumnModel.Columns.Count=0 if add columns at runtime to Grid so cannot get editor field at runtime

  1. #1

    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.

Similar Threads

  1. Replies: 1
    Last Post: May 09, 2012, 7:08 PM
  2. Replies: 2
    Last Post: Feb 09, 2010, 6:51 PM
  3. [CLOSED] [1.0] Text field added runtime looses value
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Jan 27, 2010, 6:38 AM
  4. [CLOSED] GridPanel + Dynamic Columns + Count
    By Zarzand in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 10, 2009, 4:46 PM
  5. Add Editor in GridPanel at Runtime
    By nanosassa in forum 1.x Help
    Replies: 1
    Last Post: Jul 03, 2009, 10:15 AM

Posting Permissions