This is a migrated thread and some comments may be shown as answers.

Hierarchical radgrid

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Srinivasa Rao Ranga
Top achievements
Rank 1
Srinivasa Rao Ranga asked on 22 Sep 2010, 06:40 AM

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

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 27 Sep 2010, 12:11 PM
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
Tags
Grid
Asked by
Srinivasa Rao Ranga
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or