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

Save Runtime (end-users) Configuration

7 Answers 282 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kdev
Top achievements
Rank 1
kdev asked on 28 Aug 2007, 09:55 AM

Hi all,

RadGridView allows end-users to:
- reorder columns at runtime,
- Group data by column,
- resize columns,
- perform filtering operations
- apply conditional formatting to grid elements ….

But is there a way to save and restore this configuration (to an XML or binary file, by code!!)
So next time you run your application, you haven’t to perform same modification
Is there any work around this issue?

Regards
kort

7 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 28 Aug 2007, 04:48 PM
Hello kdev,

Yes, this is a nice feature to have. We have had other people requesting at as well, so we will do our best to speed up its implementation.
 
Unfortunately, there is no workaround at the moment. Please, expect to have the saving grid's configuration feature in one of our next releases.

 
Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Emanuele Savarese
Top achievements
Rank 1
answered on 01 Sep 2007, 12:32 PM

I created a couple of code to save in XML each my grid structure.

It's working and all people can use this code
but remember
THIS IS NOT TELERIK CODE
,
I am a simple RadControls developer that created in this days a simple workaround to save columns structure with user customization.

Actually i save this column properties (but you can extends):
Type,
DataType,
DataTextFormat,
TextAlignment,
user changed Width,
user change OrderIndex,
user Visibility (if this property it's false user don't view column but he found it in ColumnChooser).

I created an user-template XML.
I load it when user customize XML is not present.
I used .NET Isolated Storage because give a simple way to save this user non-critical information in a auto-created low permissions disk space, but you can choose way you prefer. Just three step.

1. Create a collection of this class to create a schema definition of all your columns and serialize to XML.

    public class RadColumnDefinition  
    {  
        #region Public properties  
        #region --> Type  
        private string _type;  
        /// <summary> 
        /// Ottiene o imposta il tipo di editor associato alla colonna della griglia  
        /// </summary> 
        public string Type  
        {  
            get { return _type; }  
            set { _type = value; }  
        }  
        #endregion  
        #region --> DataField  
        private string _dataField;  
        public string DataField  
        {  
            get { return _dataField; }  
            set { _dataField = value; }  
        }  
        #endregion  
        #region --> HeaderText  
        private string _headerText;  
        public string HeaderText  
        {  
            get { return _headerText; }  
            set { _headerText = value; }  
        }  
        #endregion  
        #region --> Width  
        private int _width;  
        public int Width  
        {  
            get { return _width; }  
            set { _width = value; }  
        }  
        #endregion  
        #region --> IsVisible  
        private bool _isVisible;  
        public bool IsVisible  
        {  
            get { return _isVisible; }  
            set { _isVisible = value; }  
        }  
        #endregion  
        #region --> TextAlignment  
        private ContentAlignment _textAlignment = ContentAlignment.MiddleLeft;  
        public ContentAlignment TextAlignment  
        {  
            get { return _textAlignment; }  
            set { _textAlignment = value; }  
        }  
        #endregion  
        #region --> ReadOnly  
        private bool _readOnly;  
        public bool ReadOnly  
        {  
            get { return _readOnly; }  
            set { _readOnly = value; }  
        }  
        #endregion  
        #region --> DataTextFormatString  
        private string _dataTextFormatString;  
        public string DataTextFormatString  
        {  
            get { return _dataTextFormatString; }  
            set { _dataTextFormatString = value; }  
        }  
        #endregion  
        #region --> TypeName  
        private string _typeName;  
        public string TypeName  
        {  
            get { return _typeName; }  
            set { _typeName = value; }  
        }  
        #endregion  
        #region --> DataType  
        private Type _dataType;  
        [XmlIgnore()]  
        public Type DataType  
        {  
            get  
            {  
                if (_dataType == null)  
                    _dataType = System.Type.GetType(_typeName);  
                else if (_dataType.FullName != _typeName)  
                    _dataType = System.Type.GetType(_typeName);  
 
                return _dataType;                  
            }  
        }  
        #endregion  
        #region --> UniqueName  
        private string _uniqueName;  
        public string UniqueName  
        {  
            get { return _uniqueName; }  
            set { _uniqueName = value; }  
        }  
        #endregion  
        #endregion  
    } 


2. Deserialize XML and create columns with this code before setting DataSource property of GridView. In code variable "columns" is collection of RadColumnDefinition objects.

            template.Columns.BeginUpdate();  
            GridViewDataColumn colObject = null;  
            foreach (RadColumnDefinition curCol in columns)  
            {  
                switch (curCol.Type)  
                {  
                    case "GridViewTextBoxColumn":  
                        colObject = new GridViewTextBoxColumn(curCol.DataField);  
                        break;  
 
                    case "GridViewBooleanColumn":  
                        colObject = new GridViewBooleanColumn(curCol.DataField);  
                        break;  
 
                    case "GridViewDecimalColumn":  
                        colObject = new GridViewDecimalColumn(curCol.DataField);  
                        break;  
 
                    case "GridViewDataColumn":  
                        colObject = new GridViewDataColumn(curCol.DataField);  
                        break;  
                }  
 
                if (colObject != null)  
                {  
                    colObject.DataType = curCol.DataType;                      
                    colObject.HeaderText = curCol.HeaderText;  
                    colObject.Width = curCol.Width == 0 ? 15 : curCol.Width;  
                    colObject.TextAlignment = curCol.TextAlignment;  
                    colObject.VisibleInColumnChooser = true;  
                    colObject.IsVisible = curCol.IsVisible;  
                    colObject.ReadOnly = curCol.ReadOnly;                      
                    colObject.DataTextFormatString = curCol.DataTextFormatString;  
                    colObject.UniqueName = curCol.UniqueName;  
                    template.Columns.Add(colObject);  
                }  
            }  
            template.Columns.EndUpdate();  
 



3. When user close grid save user customize XML structure with this code. Variable template is intended as MasterGridViewTemplate

            foreach (GridViewDataColumn curCol in template.Columns)  
            {  
                RadColumnDefinition curDefCol = new RadColumnDefinition();  
                curDefCol.DataField = curCol.DataField;  
                curDefCol.HeaderText = curCol.HeaderText;  
                curDefCol.Type = curCol.GetType().Name;  
                curDefCol.Width = curCol.Width;  
                curDefCol.TextAlignment = curCol.TextAlignment;  
                curDefCol.IsVisible = curCol.IsVisible;  
                curDefCol.ReadOnly = curCol.ReadOnly;  
                curDefCol.TypeName = curCol.DataType.FullName;  
                curDefCol.UniqueName = curCol.UniqueName;  
                curDefCol.DataTextFormatString = curCol.DataTextFormatString;  
                columns.Add(curDefCol);  
            }   

I hope this code is useful to find your way

0
Jack
Telerik team
answered on 03 Sep 2007, 05:00 PM
Hello Arcangelo,

Thank you for sharing your solution with the community - your points have been updated. This is a nice feature with good implementation. Currently we are working on a more general solution and it will be available in one of our next versions.
 

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
David
Top achievements
Rank 1
answered on 23 Sep 2008, 03:16 AM
Is the a current Telerik solution for this problem.

I know it was going to be introduced but cannot see a solution yet from Telerik? None of the events in the demo show the option to save users customization such as column width, column height, column order and column choose inclusions/exclusions.

Any help would be greatly appreciated.


0
Nick
Telerik team
answered on 24 Sep 2008, 07:43 AM
Hi David,

Thank you for your interest in RadGridView control. I am happy to tell you that we have such example now. Just take a look at our example applications, RadGridView section, Save/Load Layout example.

Don't hesitate to contact me if you have further questions.


Best wishes,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David
Top achievements
Rank 1
answered on 24 Sep 2008, 10:05 AM
Thanks Nick.

I downloaded the latest and checked the demo.

It's great.

Just one question. I note that we can save column width, hide columns and column position.

How about Row Height?
Some of our users will be displaying pictures that they don't just want to see as thumbs. They want to expand the row height at run-time and save the height of the row as well. Thr height will vary from one user to another.

Any way row heights can be saved as well?

0
Nick
Telerik team
answered on 24 Sep 2008, 10:42 PM
Hello David,

Thank you for your feedback. Unfortunately, we do not support saving the row height, but we will consider implementing this feature as we always strive to improve our controls.

Don't hesitate to contact me if you have further questions.

Greetings,
Nick
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
kdev
Top achievements
Rank 1
Answers by
Jack
Telerik team
Emanuele Savarese
Top achievements
Rank 1
David
Top achievements
Rank 1
Nick
Telerik team
Share this question
or