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

Getting RadGrid Column Header order.

3 Answers 671 Views
Grid
This is a migrated thread and some comments may be shown as answers.
omm
Top achievements
Rank 2
omm asked on 13 Jul 2010, 08:00 PM
Hi,

How can i able to get the order of Column headers in rad grid.

grdtst.HeaderRow.Cells[i].Text; - this is the way we get header row text from ASP.NET Gridview but in RadGrid i didnt found any option like this.

please help me out of this.

Thanks in adv
-- omm --

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Jul 2010, 07:18 AM
Hello,

You could use the ColumnUniqueName property in order to identify the cell of interest.

Server code:
GridHeaderItem headerItem = RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
// fetch the data with headerItem["ColumnUniqueName"].Text

Accessing cells and rows

-Shinu.
0
omm
Top achievements
Rank 2
answered on 21 Jul 2010, 10:48 AM
hello shinu,

Thanks for ur answer... but still my problem has not been solved because i used looping to go through each column and accessing the headers, according to my code it is giving only the static columns created in ItemTemplate is only coming in count,  is there any way to get the count of all the columns (static and dynamically loaded columns). please refer the code i have used;

StringBuilder

 strbldr = new StringBuilder();

 

 

for (int i = 0; i < RadGrid2.Columns.Count; i++)

 

{

strbldr.Append(RadGrid2.Columns[i].HeaderText.ToString());

strbldr.Append(

",");

 

}

 

return strbldr.ToString();

 

0
Accepted
Daniel
Telerik team
answered on 26 Jul 2010, 09:25 AM
Hello Om,

Please try the following:
foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns)
{
    if(!(column is GridRowIndicatorColumn || column is GridExpandColumn || column is GridGroupSplitterColumn))
    {
        column.HeaderText...           
    }
}

Regards,
Daniel
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
omm
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
omm
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or