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

How to drag and drop to show/hide columns from a column chooser listbox?

10 Answers 263 Views
GridView
This is a migrated thread and some comments may be shown as answers.
z
Top achievements
Rank 1
z asked on 12 Aug 2014, 08:41 AM
We want to allow user to drag and drop to show/hide columns from a column chooser listbox. I am following the example code in http://www.telerik.com/help/wpf/radgridview-how-to-show-hide-columns-outside-of-the-radgridview.html.  We want to allow user to be able to drag a column from the list box and drop it in the column header of the grid. So it will be easy for user to design their grid columns layout.  Is there an example to do that?

10 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Aug 2014, 07:56 AM
Hi,

As an example, you can check the "Tree to Grid Drag" example in WPF Demos. It illustrates how to drag and drop between different controls.
You can also check our online documentation on DragDropManager.


Regards,
Didie
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.
 
0
z
Top achievements
Rank 1
answered on 13 Aug 2014, 08:28 AM
Hi Didie,

Thanks for your reply. My question is more specific about how
to drag a field to the Grid’s column header area, so the added column will be put
at the exact dropped location . Here is an example from Infragistics grid, and we want
to implement a similar function by using Telerik grid. The following screenshot
is an example.  Do you know how to locate
the dropped location in the grid’s column header area?
0
z
Top achievements
Rank 1
answered on 13 Aug 2014, 08:33 AM
Please check the attached image for the screenshot about the function we want.
0
Dimitrina
Telerik team
answered on 14 Aug 2014, 10:32 AM
Hello,

We do not have such an exact demo, however, you can implement the desired functionality yourself through the events DragDropManager exposes.
Since the GridView handles the basic drag and drop events internally, you need to subscribe to them with HandledEventsToo parameter set to true. You can refer to the WPF Demos for examples on different use cases on drag and drop.

Would you please try doing so and let me know if you encounter any problem?

Regards,
Didie
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.
 
0
z
Top achievements
Rank 1
answered on 18 Aug 2014, 08:38 AM
We are evaluating the Telerik grid controls, and the drag to show/hide columns from a column chooser is one of the basic functions required.  Otherwise we will have to switch to the Infragistic one.  Can you provide an example for our case, especially about how to locate where to insert the column when drop between 2 columns headers.  In the screenshot from previous post, we want to drop to add "OrderID" column between CustomerID and OrderDate, can you provide an example about how to implement it?
0
z
Top achievements
Rank 1
answered on 18 Aug 2014, 02:50 PM
 I guess you must have
implement a similar function for drag/drop to reorder the column header.  How do you locate the drop position to move
the column between the column header?
0
Dimitrina
Telerik team
answered on 20 Aug 2014, 04:16 PM
Hello,

I am working on preparing a sample project based on your requirement. I will attach it here.

Regards,
Didie
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.
 
0
Dimitrina
Telerik team
answered on 22 Aug 2014, 02:21 PM
Hello,

I attached a demo project illustrating how you can implement the required functionality.

Regards,
Didie
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.
 
0
Mehdi
Top achievements
Rank 1
answered on 18 Oct 2017, 11:56 AM

Hello,

 

We have been looking for you sample "DragDropColumns-listBox", it does the job BUT it seems that we are not anymore able to drag and drop gridview columns to the "grouping header".

Can you please tell us if this is a bug or if we still can use this feature in such context.

 

Thank you

0
Martin Ivanov
Telerik team
answered on 20 Oct 2017, 08:06 AM
Hello Mehdi,

This happens because the Effects of the drag/drop operation are set to None in the DragOver event handler. To change this you can remove this setting from the GridViewDragDropBehavior class.
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
    var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData");
    if (draggedItem == null)
    {
        //remote this line// e.Effects = DragDropEffects.None;
        return;
    }
    // some other code here
}
I hope this helps.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
z
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
z
Top achievements
Rank 1
Mehdi
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or