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

Save and Load layout from database field

1 Answer 303 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Art
Top achievements
Rank 1
Art asked on 13 May 2014, 04:40 AM
Is there an easy way to save and load a layout directly from a database field, i.e. an Oracle clob field assigned to a string field, without having to save it to disk. I could also use a blob field and an array, but since it's just a xml file a clob would be better.

Later
Art

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 May 2014, 02:53 PM
Hello Art,

Thank you for writing.

Save/Load layout functionality gives your applications the opportunity to preserve user grid settings such as column order and restore them later. Those layout settings are written in a xml file. You can use one of the three overloads of the SaveLayout method in order to store the xml content into a file, a stream or a XmlWriter. Here is a sample code snippet, demonstrating how easy you can store the grid layout into a string and afterwards it is possible to store this string content into the database. The load layout functionality will include loading this string into a MemoryStream and then using this MemoryStream for the RadGridView.LoadLayout method:
string layout = string.Empty;
 
private void radButtonSave_Click(object sender, EventArgs e)
{
    using (MemoryStream ms = new MemoryStream())
    {
        radGridView1.SaveLayout(ms);
        layout = Encoding.ASCII.GetString(ms.GetBuffer(), 0, (int)ms.Length);
    }
}
 
private void radButtonLoad_Click(object sender, EventArgs e)
{
    if (layout != string.Empty)
    {
        MemoryStream contentStream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(layout));
        this.radGridView1.LoadLayout(contentStream);
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Art
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or