Hierarchical radgrid

2 posts, 0 answers
  1. Srinivasa Rao Ranga
    Srinivasa Rao  Ranga avatar
    20 posts
    Member since:
    May 2010

    Posted 22 Sep 2010 Link to this post

    Hi,


    i need a help to create a new row on the click of a radgrid row,the newly created row shoulld come exactly below the row we clicked,and the both the rows the one we clicked on and the row created should be merged to on cell,pls help me


    Refering the radgrid in the attached figure how can we

    1. based on a client event say on row mouse click on 1st row, I need to insert an empty row below the row on which mouse click event is raised.
    2. and the 1st column for the newly inserted rows should be merged.


    Refering the radgrid in the above figure how can we freeze the 1st 3 columns

    where remaining columns can be scrollable

  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 27 Sep 2010 Link to this post

    Hello,

    RadGrid is data-bound control and its items are created based on the records in its datasource and display the datasource data. Therefore, in order to add new row in the grid, you need to add new record in its datasource and rebind the grid.

    To your second question, you can try to extend a cell if its value is the same as a value in the next row cell, by increasing its RowSpan and making the next row cell invisible as shown below:
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
        
            for (int rowIndex = RadGrid1.Items.Count - 2; rowIndex >= 0; rowIndex--) 
            
                GridDataItem row = RadGrid1.Items[rowIndex]; 
                GridDataItem previousRow = RadGrid1.Items[rowIndex + 1]; 
                if (row["ColumnUniqueName"].Text == previousRow["ColumnUniqueName"].Text) 
                
                    row["ColumnUniqueName"].RowSpan = previousRow["ColumnUniqueName"].RowSpan < 2 ? 2 : previousRow["ColumnUniqueName"].RowSpan + 1; 
                    previousRow["ColumnUniqueName"].Visible = false
                
            
        }

    As for freezing columns, you can achieve that by setting ClientSettings -> Scrolling -> FrozenColumnsCount to the desired number, as demonstrated in the following online demo.

    Regards,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top