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

save column chooser selection

6 Answers 339 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dee Gupta
Top achievements
Rank 1
Dee Gupta asked on 23 Oct 2009, 06:57 AM
I want to save the selection made by user in radgridview column chooser so on next time binding the grid we can hide the columns selected by user.I didn't find any event that is fired so I can save the items added in column chooser.Is there any way to do so?

6 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 23 Oct 2009, 08:57 AM
Hi Dee Gupta,

You can use two possible solutions for this situation.

1) Set AutoGenerateColumns property of GridViewTemplate to false and when you re-bind, your Column collection will not change.

2) Save one List with your invisible columns (IsVisible == false), rebind, handle DataBindingComplete event, and hide the generated columns using your previous saved List of invisible columns.

All the best,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dee Gupta
Top achievements
Rank 1
answered on 23 Oct 2009, 09:06 AM
Thanks for quick reply.

You suggested

2)Save one List with your invisible columns (IsVisible == false), rebind, handle DataBindingComplete event, and hide the generated columns using your previous saved List of invisible columns

I need to know at what event should I save the column list so I can use it while next time binding the grid.
0
Zak
Top achievements
Rank 1
answered on 30 Jan 2015, 06:05 AM
Hi Everyone,
I am using Column Chooser so that I can drag column from Grid view which I don't required so
for e.g I choose 3 column(Name, Date, Age) and I dragged into chooser  and I exit that Application and again If Run that Application I want that the column which I dragged into chooser as above mentioned I want that the column should remain in chooser only.
For this process My Sir has given some hint that make text file and save the columns which are there in chooser 
So how it possible please help Me.
0
Hristo
Telerik team
answered on 03 Feb 2015, 03:50 PM
Hi Zakariya,

Thank you for writing.

You could accomplish this type of behavior by using our SaveLayout and LoadLayout methods. Please refer to the following article for more information. I have also prepared a code snippet which you can see below:
public partial class Form1 : Form
{
    private string layout;
 
    public Form1()
    {
        InitializeComponent();
 
        this.FormClosing +=Form1_FormClosing;
        this.layout = @"..\..\..\layout.xml";
    }
 
    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        this.radGridView1.SaveLayout(layout);
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        this.productsTableAdapter.Fill(this.nwindDataSet.Products);
        if (File.Exists(layout))
        {
            this.radGridView1.LoadLayout(layout);
        }
    }
}

I hope this information helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Chris Kirkman
Top achievements
Rank 1
answered on 08 Jan 2018, 03:32 PM
This worked for me.  It was a last ditch effort though.  I didn't want to wait until the form closed before calling .SaveLayout().  I wanted to know the instant a user added/removed a column via the column chooser; however, this ended up working.
0
Hristo
Telerik team
answered on 09 Jan 2018, 09:53 AM
Hi Chris,

I am glad that you have found a suitable for your actual scenario solution.

Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Dee Gupta
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Dee Gupta
Top achievements
Rank 1
Zak
Top achievements
Rank 1
Hristo
Telerik team
Chris Kirkman
Top achievements
Rank 1
Share this question
or