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

AllowDrop = True for all aspects of the RadGridView

4 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 10 Dec 2013, 04:28 PM
Hello,

We are using a RadGridView and have ListBoxes which we can drag items from into custom cells that contain Listboxes to received dropped items. The DragAndDrop works great, the issue is that most of the components that make up a RadGridView have AllowDrop=True which causes our items to disappear (seen easily in XAML/Silverlight Spy). Normally we use AllowDrop very selectively on only the places we desire. AllowDrop on the RadGridView itself is set to false, and I have managed to set AllowDrop on much of the grid by doing this:
private void RadGridView_RowLoaded(object sender, RowLoadedEventArgs e)
{
    e.Row.AllowDrop = false;
}

But we are also using Grouping, and the grouping panel has it set to True automatically. Using a style to set it isn't going to work, as in:
<telerik:RadGridView.GroupRowStyle>
      <Style TargetType="telerik:GridViewGroupRow">
           <Setter Property="AllowDrop" Value="False"/>
      </Style>
</telerik:RadGridView.GroupRowStyle>

because we use an application theme but use a different theme on this RadGridView (Summer) and setting the style this way causes just the grouping row to inherit from the application theme (a different issue, See Here). This solves the drag issue for us, but creates a visual issue. See Attached image.

I have tried subscribing to the grouping events Grouped and Grouping, but they don't seem to be firing, perhaps that is because we are creating the group in code using a ColumnGroupDescriptor instead of clicking through the UI.

This below however works on a single row after the user has clicked it, but before the user clicks it the AllowDrop is still True, if we could run that single line of code on all group rows, I think we'd be all set for this issue.
private void RadGridView_GroupRowIsExpandedChanged(object sender, GroupRowEventArgs e)
{
    ((GridViewGroupRow)e.Row).AllowDrop = false;
}

To note:
  • RadGridView Theme is Summer, Application theme is Expression_Dark
  • Listboxes we drag from use a CustomListBoxDragDropBehavior, we override CanDrop but returning false on it doesn't stop the "Drop" into the grid

How can we across the board disable AllowDrop on a RadGridView and only selectively turn it on for parts we want, or is there something else/other method we should be doing?
 
Thank you,
Patrick

4 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 10 Dec 2013, 06:35 PM
Hello,

We tried something that has seemed to work, this was combined with the rowloaded event:

public class RadGridViewWithOverride : RadGridView
    {
        protected override void PrepareContainerForGroupItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForGroupItemOverride(element, item);
 
            //set control dragDrop
            var uiElement = element as UIElement;
            if (uiElement != null)
            {
                uiElement.AllowDrop = false;
            }
        }
    }

Questions now are:
  • Do you recommend against this method to achieve what we need?
  • If this is ok, what is the best way to include e.Row.AllowDrop = false; in the derived RadGridViewWithOverride class?

Thanks,
Patrick
0
Nick
Telerik team
answered on 13 Dec 2013, 12:56 PM
Hello Patrick,

Most of the components of the GridView have to be Drop responsive (AllowDrop = true) in order for the internal drag drop logic to work. 

The best way to disable the drop is to get the DragOver event and set the effects to none if a target is a no drop area.

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Patrick
Top achievements
Rank 1
answered on 13 Dec 2013, 02:48 PM
Nik,

Do you mean the events on the RadGridView? These don't seem to be firing when dragging from our listbox.
DragOver="RadGridViewWithOverride_DragOver" DragEnter="RadGridViewWithOverride_DragEnter" Drop="RadGridViewWithOverride_Drop"

Thanks,
Patrick
0
Nick
Telerik team
answered on 18 Dec 2013, 12:06 PM
Hello Patrick,

The events that I was referring to are the ones included in the DragDropManager. 
You can see more information about how to implement them here.

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Nick
Telerik team
Share this question
or