Chris Kirkman
Top achievements
Rank 1
Chris Kirkman
asked on 08 Jan 2018, 08:55 PM
I need to be able to programmatically get a list of the column headers that are currently being displayed in the grid. I.e. my grid has 8 columns; however, the user may have changed the order and hidden some of the remaining columns (via the column chooser).
How do I ask the grid to give me the columns currently displayed and in left to right order?
4 Answers, 1 is accepted
0
Accepted
Hello, Chris,
Thank you for writing.
You can iterate the RadGridView.Columns collections and check whether the column is visible or not by the GridViewColumn.IsVisible property. Here is a sample code snippet:
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Thank you for writing.
You can iterate the RadGridView.Columns collections and check whether the column is visible or not by the GridViewColumn.IsVisible property. Here is a sample code snippet:
private
void
radButton1_Click(
object
sender, EventArgs e)
{
foreach
(GridViewColumn col
in
this
.radGridView1.Columns)
{
if
(col.IsVisible)
{
Console.WriteLine(col.Name);
}
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
0
Chris Kirkman
Top achievements
Rank 1
answered on 09 Jan 2018, 01:44 PM
Dess, as usual you came through for me. Thanks, that solved my problem.
How would I exclude command columns in my loop? I've tried col.RadObjectType != typeof(GridViewCommandColumn) but the compiler says I can't do this.
0
Accepted
Hello, Chris,
Thank you for writing back.
I am glad that the provided code snippet was useful for your case. In order to exclude GridViewCommandColumns, you can refer to the following code snippet:
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik
Thank you for writing back.
I am glad that the provided code snippet was useful for your case. In order to exclude GridViewCommandColumns, you can refer to the following code snippet:
foreach
(GridViewColumn col
in
this
.radGridView1.Columns)
{
if
(col.IsVisible && !(col
is
GridViewCommandColumn))
{
Console.WriteLine(col.Name);
}
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
0
Chris Kirkman
Top achievements
Rank 1
answered on 09 Jan 2018, 04:02 PM
that is perfect! thanks.