Hierarchical Grid-Add GridTableView programatically

4 posts, 1 answers
  1. Omlac
    Omlac avatar
    64 posts
    Member since:
    Jul 2008

    Posted 06 Oct 2008 Link to this post

    i would like to develop a hierarchical grid view programmatically. The firstrow(masterTableview) im adding it at design time.
    Im doing that using the code below, but its not adding the griddesignview(children for the first row) Does anyone see whats wrong with the code im using here:
    Master.ParentlocationID is matched to TableView.LocationID, im also using a dataset as my datasource.

     

    adapter.Fill(dsData);

     

     

     

     

     

    GridTableView tableSubLocation = new GridTableView(rdgLocation);

     

    rdgLocation.MasterTableView.DetailTables.Add(tableSubLocation);

    tableSubLocation.DataSource = dsData;

     

     

     

     

     

    tableSubLocation.Width =

     

     

     

     

    Unit.Percentage(100);

     

     

     

     

     

     

    GridRelationFields relationFields = new GridRelationFields();

     

    tableSubLocation.ParentTableRelation.Add(relationFields);

    relationFields.MasterKeyField =

     

     

     

     

    "LocationID";

     

    relationFields.DetailKeyField =

     

     

     

     

    "ParentLocationID";

     

     

     

     

     

     

    GridBoundColumn boundColumn;

     

    boundColumn =

     

     

     

     

    new GridBoundColumn();

     

    tableSubLocation.Columns.Add(boundColumn);

    boundColumn.DataField =

     

     

     

     

    "LocationID";

     

    boundColumn.HeaderText =

     

     

     

     

    "LocationID";

     

    boundColumn =

     

     

     

     

    new GridBoundColumn();

     

    tableSubLocation.Columns.Add(boundColumn);

    boundColumn.DataField =

     

     

     

     

    "Location";

     

    boundColumn.HeaderText =

     

     

     

     

    "Location";

     

     

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Oct 2008 Link to this post

    Hi Omlac,

    "RadGrid does not support mixing declarative grid columns with grid columns added dynamically at runtime. You should either create all the columns in the grid programmatically, or else define them all in the ASPX file."

    Check out the link below for more information on programmatic creation of hierarchial grid.

    http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

    Thanks,
    Princy

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Omlac
    Omlac avatar
    64 posts
    Member since:
    Jul 2008

    Posted 06 Oct 2008 Link to this post

    Thank you very much,
     Im sorry for the format of my message
  5. Bruno
    Bruno avatar
    26 posts
    Member since:
    Feb 2009

    Posted 18 Feb 2009 Link to this post

    Hello,

    and what if I want to programmatic add a new column to an existing Detail Table?

    something like that.

    <MasterTableView> 
       <detailtables> 
            <Gridtableview> 
     
                <columns> 
                  <gridboundcolumn></gridboundcolumn
                  <gridboundcolumn></gridboundcolumn
                  <gridboundcolumn></gridboundcolumn
     
                    How to insert more columns here, using the code behind? 
     
                <columns> 
            <gridtableview> 
     
       </detailtables> 
     
    <columns>......</columns> 
    <MastertableView> 

    I used this successfully to add to the master table, but I cant add to the detail table.

                    GridBoundColumn boundColumn; 
                    boundColumn = new GridBoundColumn(); 
                    RadGrid1.MasterTableView.Columns.Add(boundColumn); 
                    boundColumn.DataField = "valor"
                    boundColumn.HeaderText = "Valor"
                    boundColumn.UniqueName = "valor"
                    boundColumn.DataFormatString = "{0:R$###,###.##}"
    How can I do the same with DETAILTABLES ?????

    Thanxs
Back to Top