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

[Solved] Hide Empty Columns

4 Answers 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Drew
Top achievements
Rank 1
Drew asked on 17 Nov 2010, 05:52 AM
Hi,

I've produced a GridView which shows Student results over a few years. The issue I have is some years, the students may not have taken in the test, therefore a column will end up with no values. (See Screenshot).

I'm wondering if it's possible to detect and hide these empty columns?

Regards,
Drew

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Nov 2010, 10:51 AM
Hi Drew,

You may run through the Items collection of the grid and check if all of them have empty value for a particular property. Once you find this out, you may set the corresponding columns' IsVisible property to "False".
 

All the best,
Maya
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Drew
Top achievements
Rank 1
answered on 18 Nov 2010, 12:53 AM
Thanks, that was the idea I had. However I'm currently unsure of how to do this as there is no GridView.Rows property.

Obviously I need to loop through each column and check if any row has a value.

ie.
For Each Col in GridView.Columns
' Check if Any Row Has a Value
Next

How can I now loop through each row within a column? There is no Column.Row(i) Property etc.

Thanks,
Drew
0
Maya
Telerik team
answered on 18 Nov 2010, 05:07 PM
Hello Drew,

You may use the Items collection of the RadGridView. For example, if your Business Object is Club and it has a property - Name, you can check if all the names of the items are null as follows:

foreach(Club club in this.clubsGrid.Items)
{
    if(club.Name == null)
    {
    }
}  

 

All the best,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Drew
Top achievements
Rank 1
answered on 18 Nov 2010, 10:12 PM
Thankyou Maya. I must have missed the Items collection!

Regards,
Drew
Tags
GridView
Asked by
Drew
Top achievements
Rank 1
Answers by
Maya
Telerik team
Drew
Top achievements
Rank 1
Share this question
or