save column chooser selection

5 posts, 0 answers
  1. Dee Gupta
    Dee Gupta avatar
    2 posts
    Member since:
    Aug 2009

    Posted 23 Oct 2009 Link to this post

    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?
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 23 Oct 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dee Gupta
    Dee Gupta avatar
    2 posts
    Member since:
    Aug 2009

    Posted 23 Oct 2009 Link to this post

    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.
  5. Zak
    Zak avatar
    8 posts
    Member since:
    Jan 2015

    Posted 30 Jan 2015 Link to this post

    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.
  6. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 03 Feb 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready