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

How to detect when Column Chooser is opened?

12 Answers 258 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phi
Top achievements
Rank 1
Phi asked on 31 Oct 2010, 02:40 AM
I have 2 RadGridView controls on the same form using RadDock to host them both. On one grid, I allowed Column Chooser. The other grid, I do not. When switching between the two grids, the column chooser still visible when going to the grid that does not allow column chooser. How do I detect whether the Column Chooser is opened so I could close/hide it when needed?

PS: This is another weird thing: when I switched to the 2nd grid (which does not allow column chooser), I am able to drag the column header(s) to the column chooser to hide the column(s). The column(s) did disappear but nothing is showed on in the column chooser. There is no way to restore the hidden column(s) back!

Thanks,

Phi

12 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 01 Nov 2010, 10:14 PM
Hello,

You can just use:
if (grid.ColumnChooser.Visible)
{
    // do something or
    grid.ColumnChooser.Close();
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Phi
Top achievements
Rank 1
answered on 02 Nov 2010, 02:46 AM
The funny thing is: The visible property equaled to true when going to a grid that allows column chooser. When switching to a grid that does not allow column chooser, the visible property is equaled to false but the darn column chooser is still visible. This indicated that each grid has its own column chooser. I just have to work around it in the changing event instead in the changed event.

Thanks,

Phi
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 02 Nov 2010, 06:55 AM
Hello again,

Sorry i have oversimplified things... But i was thinking something you were doing some checks when you are switching tabs and just wanted to know how to close it.
Anyway, i would propose two options:
1. Whenever you switch tabs, just check if column chooser is visible and close it if it is (simplest one)
2. If you only have 2 grids, you could handle the GotFocus event of both of the grids, and check if the other one has the column chooser open (ugly solution but i will work the same) and then close it.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
0
Jack
Telerik team
answered on 03 Nov 2010, 03:56 PM
Hi Phi,

I confirm the issue, we will address it in our upcoming Q3 release which will be available in the end of the next week. I hope this time frame is acceptable for you. If you have further questions, do not hesitate to ask.

Regards,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Phi
Top achievements
Rank 1
answered on 03 Nov 2010, 05:57 PM
I have no problem with the time frame. I know there is a lot of work involved in something like this. Just want to point out things so you guys could fix or improve your products. Ha ha, in another thought, you may want to get better testers :)
0
Jack
Telerik team
answered on 09 Nov 2010, 06:37 PM
Hi Phi,

Thank you for your feedback. We take seriously all issues reported by our customers and we will appreciate any ideas on how to improve our products. 

If you have any other ideas or feedback, please do not hesitate to share them with us.

Best wishes, Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ofer
Top achievements
Rank 1
answered on 19 Jan 2012, 11:08 AM
Hi Jack.
I work in Q3.
1. is there any  way to catch the columnchooser event  when its opened but not only at the first time?
2. is there any  way to catch the columnchooser event  when column drags in to it? 
i tried the got-Focus and the load and the shown  and the visible  etc for 1 and all the drag-event-Handler for 2. no one works
The thing is that i have 2 Grids that are same and i want that when the user opened one columnchooser the other will opened as well and when he drag drop a column i want to drag for him the same column as well from the other grid to it's own columnchooser.
the problem is that i can't find event that occurs when the drag-and-drop finished (DragDrop doesn't work )  

thanks Ofer
0
Nikolay
Telerik team
answered on 19 Jan 2012, 12:43 PM
Hello Ofer,

Before addressing your questions, we would kindly ask you to provide the information that we requested in your thread "Borders and RTL in Export to excel". After we receive and confirm the information that you will provide there, we will be able to assist you further.

Kind regards,
Nikolay
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Ofer
Top achievements
Rank 1
answered on 19 Jan 2012, 02:30 PM
Hi Nikolay,
I am licensed now.
Can you please help me.
Ofer.
0
Ofer
Top achievements
Rank 1
answered on 23 Jan 2012, 10:04 AM
Hi again  Nikolay,
You told me that if i'll be register and licensed you will help me.  
I already told  you that i did what you asked me. You can check it.
So can you please help me 
Ofer. 
0
Jack
Telerik team
answered on 24 Jan 2012, 10:37 AM
Hi Ofer,

Thank you for updating your account details. Directly to your questions:

1. RadGridView creates a new column chooser every time when opening it. The best option in this case is to replace the default menu item with a custom one and attach to the Shown event every time when showing the column chooser:

this.radGridView1.ContextMenuOpening += new ContextMenuOpeningEventHandler(radGridView1_ContextMenuOpening);
 
void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    string columnChooserMenuItem = Telerik.WinControls.UI.Localization.RadGridLocalizationProvider
            .CurrentProvider.GetLocalizedString(Telerik.WinControls.UI.Localization.RadGridStringId.ColumnChooserMenuItem);
 
 
    int i = 0;
    foreach (RadMenuItemBase item in e.ContextMenu.Items)
    {
        if (item.Text == columnChooserMenuItem)
        {
            e.ContextMenu.Items.RemoveAt(i);
            RadMenuItem newColumnChooserMenuItem = new RadMenuItem(columnChooserMenuItem);
            newColumnChooserMenuItem.Click +=new EventHandler(newColumnChooserMenuItem_Click);
            e.ContextMenu.Items.Insert(i, newColumnChooserMenuItem);
            break;
        }
        i++;
    }
}
 
void newColumnChooserMenuItem_Click(object sender, EventArgs e)
{
    this.radGridView1.ColumnChooser.Shown += new EventHandler(ColumnChooser_Shown);
    this.radGridView1.ShowColumnChooser(this.radGridView1.CurrentCell.ViewTemplate);
}
 
void ColumnChooser_Shown(object sender, EventArgs e)
{
    GridViewColumnChooser columnChooser = (GridViewColumnChooser)sender;
    columnChooser.Shown -= new EventHandler(ColumnChooser_Shown);
    MessageBox.Show("Text");
}

2. In this case you should get the RadDragDropService from GridViewElement property by using the GetService method. Then you should handle the PreviewDragDrop event. Here is a sample:

RadDragDropService dragDropService = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
dragDropService.PreviewDragDrop += new EventHandler<RadDropEventArgs>(dragDropService_PreviewDragDrop);
 
void dragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
{
    ColumnChooserVisualElement element = e.HitTarget as ColumnChooserVisualElement;
    if (element != null)
    {
        MessageBox.Show("Dropped!");
    }
}

You can get the dragged column by accessing the e.DragInstance property.

Please, note that forum posts are handled within 72 hours and support tickets are handled according to your license agreement

I hope this helps. If you need further assistance, do not hesitate to write back.
 
All the best,
Jack
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Ofer
Top achievements
Rank 1
answered on 26 Jan 2012, 04:08 PM
Thanks Jack.
Tags
GridView
Asked by
Phi
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Phi
Top achievements
Rank 1
Jack
Telerik team
Ofer
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or