Add a Column to an existing DetailTable via the code behind

7 posts, 1 answers
  1. 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
  2. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 18 Feb 2009 Link to this post

    GridBoundColumn boundColumn; 
    boundColumn = new GridBoundColumn(); 
    RadGrid1.MasterTableView.Columns.Add(boundColumn); 
    boundColumn.DataField = "valor"
    boundColumn.HeaderText = "valor";
    boundColumn.UniqueName = "valor"
    boundColumn.DataFormatString = "{0:R$###,###.##}";

     
    GridTableView tableViewOrders = new GridTableView(RadGrid1); 

    That should do what you are wanting.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bruno
    Bruno avatar
    26 posts
    Member since:
    Feb 2009

    Posted 18 Feb 2009 Link to this post

    Boone
    In this code you are creating a new GridTableView.

    GridTableView tableViewOrders = new GridTableView(RadGrid1);  

    What I want to do is to Append a new Column in to a first level existing Detail Table.

    or some way to create all columns in the ASPx file and after that starting to hide columns depending on logged user.




  5. Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 18 Feb 2009 Link to this post

    This is the piece that does the trick. That last line was something else I was playing with and forgot to remove it for your problem.

    RadGrid1.MasterTableView.Columns.Add(boundColumn);  

  6. Bruno
    Bruno avatar
    26 posts
    Member since:
    Feb 2009

    Posted 18 Feb 2009 Link to this post

    I Already have this line take a look again in my piece of code.

                    GridBoundColumn boundColumn;  
                    boundColumn = new GridBoundColumn();  
                    RadGrid1.MasterTableView.Columns.Add(boundColumn);  
                    boundColumn.DataField = "valor";  
                    boundColumn.HeaderText = "Valor";  
                    boundColumn.UniqueName = "valor";  
                    boundColumn.DataFormatString = "{0:R$###,###.##}";  

    This line do the work just for the root level, this one will add a column in to MASTER TABLE

    I Need to add a column into DetailTable.

    something like
                    RadGrid1.MasterTableView.DetailTable.Columns.Add(boundColumn); 
    (but that doenst work as well..)

  7. Answer
    Boone
    Boone avatar
    47 posts
    Member since:
    May 2008

    Posted 18 Feb 2009 Link to this post

    RadGrid1.MasterTableView.DetailTables[0].Columns.Add( boundColumn); ?

  8. Bruno
    Bruno avatar
    26 posts
    Member since:
    Feb 2009

    Posted 18 Feb 2009 Link to this post

    PERFECT!!

    This works fine !!

    Thank you Boone

                    GridBoundColumn boundColumn; 
                    boundColumn = new GridBoundColumn(); 
                    RadGrid1.MasterTableView.Columns.Add(boundColumn); 
                    boundColumn.DataField = "valor"
                    boundColumn.HeaderText = "Valor"
                    boundColumn.UniqueName = "valor"
                    boundColumn.DataFormatString = "{0:R$###,###.##}"
     
     
     
                    GridBoundColumn boundColumn1; 
                    boundColumn1 = new GridBoundColumn(); 
                                      
                  RadGrid1.MasterTableView.DetailTables[0].Columns.Add(boundColumn1); 
                    boundColumn1.DataField = "valor"
                    boundColumn1.HeaderText = "Valor"
                    boundColumn1.UniqueName = "valor"
                    boundColumn1.DataFormatString = "{0:R$###,###.##}"
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017