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

How to Saving grid settings on a per user basis

12 Answers 301 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nikhil Jain
Top achievements
Rank 1
Nikhil Jain asked on 21 Jan 2011, 10:19 AM
Hi

I want to know how can I Saving grid settings (Reordering of Grid Column)  on a per user basis.

Regards

12 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Jan 2011, 10:23 AM
Hello,

Have you checked this demo

All the best,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Nikhil Jain
Top achievements
Rank 1
answered on 25 Jan 2011, 01:08 PM
This demo, is not showing how to save settings for a RadGrid when user Reorders the columns.!
0
Maya
Telerik team
answered on 25 Jan 2011, 01:14 PM
Hi Nikhil Jain,

You may expose a new property in the ColumnSettings class - DisplayIndex for example that save the original DisplayIndex property of each column.
 

Best wishes,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Nikhil Jain
Top achievements
Rank 1
answered on 27 Jan 2011, 07:01 AM
Thanks for your reply.!
If you provide me sample that would me great and more helpful for me.
0
Maya
Telerik team
answered on 27 Jan 2011, 08:53 AM
Hi Nikhil Jain,

May you take another look at our demos considering the Save and Load RadGridView Layout Settings ? The ColumnSetting class exposes the above-mentioned property - DisplayIndex that keeps the value of the DisplayIndex property of each column. Consequently, once you reorder the columns, their index will be save and loaded again afterwards. Do you have any troubles with this particular example ? 

 

Regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Nikhil Jain
Top achievements
Rank 1
answered on 27 Jan 2011, 11:02 AM
Hi Maya

I am having an Error message : "GridViewDataControl_ColumnDisplayIndexOutOfRange Sales Use
Parameter name: displayIndex"
public class ColumnSetting : PropertySetting
   {
       public string UniqueName { get; set; }
       public object Header { get; set; }
       public double? Width { get; set; }
       public int DisplayIndex { get; set; }
   }


foreach (ColumnSetting setting in Settings.ColumnSettings)
                    {
                         
                        GridViewDataColumn column = new GridViewDataColumn();
                        column.UniqueName = setting.UniqueName;
                        column.Header = setting.Header;
                        column.DisplayIndex = setting.DisplayIndex;
                        if (setting.Width != null)
                        {
                            column.Width = new GridViewLength(setting.Width.Value);
                              
                        }
  
                        grid.Columns.Add(column);
                    }
0
Maya
Telerik team
answered on 27 Jan 2011, 01:06 PM
Hello Nikhil Jain,

May you take another look at our demos considering the Save and Load RadGridView Layout Settings and implement the code for the LoadState() method ? The code from the demo corresponding to the one you posted is:
if (this.grid != null)
           {
               grid.FrozenColumnCount = Settings.FrozenColumnCount;
 
               if (Settings.ColumnSettings.Count > 0)
               {
                   foreach (ColumnSetting setting in Settings.ColumnSettings)
                   {
                       ColumnSetting currentSetting = setting;
 
                       GridViewDataColumn column = (from c in grid.Columns.OfType<GridViewDataColumn>()
                                                    where c.UniqueName == currentSetting.UniqueName
                                                    select c).FirstOrDefault();
 
                       if (column != null)
                       {
                           if (currentSetting.DisplayIndex != null)
                           {
                               column.DisplayIndex = currentSetting.DisplayIndex.Value;
                           }
 
                           if (setting.Width != null)
                           {
                               column.Width = new GridViewLength(setting.Width.Value);
                           }
                       }
                   }
               }

This code is created against our current official release Q3 2010 SP1. What version of RadControls are you using ? 
Still, I am sending you a sample project that you may use for a reference and testing the functionality locally. 

 

Regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Remco
Top achievements
Rank 1
answered on 20 Nov 2012, 09:34 AM
Hello i try to do this with the actual 2012Q3, But i am unable to compile the SaveAndLoadSettings project that is attached in the last post and i can also not find the SaveAndLoad sample in the 2012Q3 Demosets..

Can you give me a updated solution? thanks

0
Vlad
Telerik team
answered on 20 Nov 2012, 09:56 AM
Hi,

 With 2012 Q3 you should use our Persistence Framework:
http://demos.telerik.com/silverlight/#PersistenceFramework/GridViewCustomSerialization

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Issac
Top achievements
Rank 1
answered on 05 Aug 2016, 08:54 AM
Hello Vlad,

Is there anyway to save the GridViewSettings to XML format? As I realised those demo it only save for temporary usage after I closed the application it couldn't load the settings I saved earlier. I hope there is an example which could save the gridview settings to XML format so it could load the XML settings based on each user log in. Sorry I'm new in development so hope you don't mind.

0
Stefan
Telerik team
answered on 08 Aug 2016, 11:25 AM
Hello Issac,

I am attaching a sample application demonstrating how RadGridView can be persisted in an xml file. Can you please check it out?

I hope it helps.

All the best,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Issac
Top achievements
Rank 1
answered on 10 Aug 2016, 02:35 AM
Hello Stefan,

Thanks for the sample but it couldn't run cause some of dlls is missing but is okay. I just look through the classes.

From
Issac
Tags
GridView
Asked by
Nikhil Jain
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Nikhil Jain
Top achievements
Rank 1
Maya
Telerik team
Remco
Top achievements
Rank 1
Issac
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or