dynamic creating of GridPanel Column and binding with dataset

  1. #1

    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

    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
  2. #2
    Hi,

    I don't see where you add the Store to the Page.

    As well, it's better to add the Store component directly to the GridPanels .Store Collection, instead of setting the .StoreID property.

    Example

    grid.Store.Add(myStore);
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

    I don't see where you add the Store to the Page.

    As well, it's better to add the Store component directly to the GridPanels .Store Collection, instead of setting the .StoreID property.

    Example

    grid.Store.Add(myStore);
    Hope this helps.

    hi,

    Thanks for the reply

    store is already defined in .aspx page

    <tr>
    <td>
        <ext:Store runat="server" ID="Store1" AutoDataBind="true"></ext:Store>
    </td>
    </tr>
    i tried ur suggestion but no result
    Last edited by geoffrey.mcgill; Sep 28, 2011 at 3:51 AM.

Similar Threads

  1. GridPanel with DataSet, where am I wrong?
    By MADSON in forum 1.x Help
    Replies: 4
    Last Post: Apr 08, 2012, 5:45 PM
  2. Replies: 12
    Last Post: Sep 20, 2011, 2:33 PM
  3. [CLOSED] Problem Creating Dynamic Header column for filter
    By legaldiscovery in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Jun 23, 2011, 6:59 AM
  4. Replies: 0
    Last Post: Jun 21, 2011, 12:18 PM
  5. [CLOSED] Dynamic Column in GridPanel
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 26, 2011, 11:23 AM

Tags for this Thread

Posting Permissions