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

RadGridViewSettings.cs no Hide column functionality

4 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
aubrey
Top achievements
Rank 1
aubrey asked on 03 Jun 2011, 07:44 AM
Good day Telerik Team,

I've seen your sample demos and forums about saving/loading gridview settings and  it works fine. But your RadGridViewSettings.cs does not support hide columns functionality which i really need to save as part of the gridview setting(s). 

I do need this one, can anyone help me with this functionality or maybe give me sample code(s) for this.  

Hoping for reply
Aubrey :')

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Jun 2011, 07:49 AM
Hi aubrey,

You may expose a new property IsVisible for example in the ColumnSettings class and use it for keeping the corresponding property of the columns.
 

Best wishes,
Maya
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
0
aubrey
Top achievements
Rank 1
answered on 03 Jun 2011, 08:06 AM
Hi Maya,

Thanks for your immediate reply. Am a little confused on how to mange this one, can you give me code snippet for this? :'(
am still studying your RadGridViewSettings.cs. 

Thanks
Aubrey :') 
0
Accepted
Maya
Telerik team
answered on 03 Jun 2011, 08:22 AM
Hi aubrey,

Defining a IsVisible property would be exactly the same as the others in that class:

public class ColumnSetting : PropertySetting
   {
       bool _IsVisible;
       public bool IsVisible
       {
           get
           {
               return _IsVisible;
           }
           set
           {
               _IsVisible= value;
           }
       }      
       }
   }

Setting and getting its value will be again similar to those of the other properties for the column - in the SaveState() method:
foreach (GridViewColumn column in grid.Columns)
                    {
                        if (column is GridViewDataColumn)
                        {
                            GridViewDataColumn dataColumn = (GridViewDataColumn)column;
 
                            ColumnSetting setting = new ColumnSetting();
                            setting.PropertyName = dataColumn.DataMemberBinding.Path.Path;
                            setting.UniqueName = dataColumn.UniqueName;
                            setting.Header = dataColumn.Header;
                            setting.Width = dataColumn.ActualWidth;
                            setting.DisplayIndex = dataColumn.DisplayIndex;
                            setting.IsVisible = dataColumn.IsVisible;
 
                            Settings.ColumnSettings.Add(setting);
                        }
                    }

and LoadState():
column.IsVisible= currentSetting.IsVisible;
 

Best wishes,
Maya
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
0
aubrey
Top achievements
Rank 1
answered on 03 Jun 2011, 09:11 AM
Hi Maya,

Sorry for the late reply. I've done studying your RadGridViewSettings.cs. and i also tried your code.. It works great! :')

Thank you so much Maya!! 

Regards 

Aubrey :')
Tags
GridView
Asked by
aubrey
Top achievements
Rank 1
Answers by
Maya
Telerik team
aubrey
Top achievements
Rank 1
Share this question
or