This is a migrated thread and some comments may be shown as answers.
CellDoubleClickEvent and RowReorderBehavior Issue
6 Answers 17 Views
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 2
Corey asked on 08 Nov 2013, 02:47 PM
I have a RadGridView that has an added GridViewCellBase.CellDoubleClickEvent handler that proceeds to open a dialogue.  This dialogue is modal and allows the user to edit settings related to the clicked row.

However, the grid also allows for the rows to be reordered by drag and drop.  The problem I've come across, and it's a small but annoying one, is that after the user double clicks the row and closes the dialogue that opened, apparently the row is now subscribed to the drag and drop reordering.  The user doesn't have to hold down a mouse button, but the row is being "dragged" and the user has to click somewhere on the grid to end the reordering.  If the user isn't paying attention, this may cause some undesired reordering.

Is there a way to not trigger the drag and drop reordering when double clicking a row and opening a modal dialogue?

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Nov 2013, 02:31 PM
Hi,

Please set DragElementAction="None" for RadGridView and let me know if the issue is now resolved.

Regards,
Didie
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
Corey
Top achievements
Rank 2
answered on 11 Nov 2013, 03:05 PM
Unfortunately, no, this did not resolve my issue.  After double clicking the row and closing the dialogue that was opened (as a result of the clicking), the row is selected and assumed to be in the mode for drag and drop reordering.  Below is a snippet of my code that pertains to the grid and its double click handler.  I've also included an image of what the drag and drop looks like after the dialogue has closed.  Hope this helps you help me.

Snippet for building the RadGridView (I omitted the adding of the columns since they are done manually within the code and there are a lot of them)
private void BuildGrid()
{
  _selectedColumns = (RadGridView)_lm.AddGridView().Control;
  _selectedColumns.IsReadOnly = false;
  _selectedColumns.DragElementAction =
       Telerik.Windows.Controls.GridView.Selection.DragAction.None;
  _selectedColumns.Width = _selectedColumns.MaxWidth = DlgParent.LeftWidth.Value +
       DlgParent.RightWidth.Value - 20;
  _selectedColumns.Height = _selectedColumns.MaxHeight = DlgParent.PanelHeight - 25;
  _selectedColumns.AutoGenerateColumns = false;
  _selectedColumns.ShowGroupPanel = false;
  _selectedColumns.SelectionMode = System.Windows.Controls.SelectionMode.Extended;
  _selectedColumns.IsFilteringAllowed = false;
 
  RowReorderBehavior.SetIsEnabled(_selectedColumns, true);
 
  _selectedColumns.AddHandler(GridViewCellBase.CellDoubleClickEvent,
       new EventHandler<RadRoutedEventArgs>(OnCellDoubleClick), true);
 
  _selectedColumns.ItemsSource = _viewAttributes.ViewCols;
}

Snippet for the double clicked event handler
private void OnCellDoubleClick(object sender, RadRoutedEventArgs e)
{
  if (_selectedColumns.SelectedItems.Count == 1)
       new DlgViewEditColumn((VsViewCol)_selectedColumns.SelectedItems[0], _selectedColumns,
       _viewAttributes.Action.PrimaryTable).Show();
  else
       RadWindow.Alert("Must select only one column for editing options.");
}
0
Dimitrina
Telerik team
answered on 12 Nov 2013, 03:39 PM
Hi,

Having the code you have shared, I am not sure how you have implemented the dragging.
Generally the problem seems to be that the GridView does not detect the mouse has been released after you opened the window. 
Would it be possible for you to isolate the issue in a demo project and send it to us via a support ticket?

Regards,
Didie
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
Corey
Top achievements
Rank 2
answered on 13 Nov 2013, 04:48 PM
My apologies.  I didn't realize RowReorderBehavior was one of our custom classes.  I thought it was something inherent to the RadGridView.  Here is most of the code within the RowReorderBehavior.SetIsEnabled method.  I tried turning off the drag and drop handlers when the user triggers the OnCellDoubleClick event, but it didn't help.  Closing the window still has the selected row in drag and drop mode.  I think it is that the GridView isn't detecting the mouse has been released like you said.  Hopefully these snippets might make the problem a little clearer.

SetIsEnabled method
public static void SetIsEnabled(DependencyObject obj, bool value)
{
  RowReorderBehavior behavior = GetAttachedBehavior(obj as RadGridView);
  behavior.AssociatedObject = obj as RadGridView;
 
  if (value)
    behavior.Initialize();
  else
    behavior.CleanUp();
 
  obj.SetValue(IsEnabledProperty, value);
}

Initialize method  (note that the Cleanup method seen in the snippet above removes all the handlers below)
protected virtual void Initialize()
{
  this.AssociatedObject.RowLoaded +=
    new EventHandler<Telerik.Windows.Controls.GridView.RowLoadedEventArgs>(AssociatedObject_RowLoaded);
  this.AssociatedObject.SetValue(RadDragAndDropManager.AllowDropProperty, true);
 
  RadDragAndDropManager.AddDropQueryHandler(this.AssociatedObject, OnDropQuery);
  RadDragAndDropManager.AddDropInfoHandler(this.AssociatedObject, OnDropInfo);
  RadDragAndDropManager.AddDragQueryHandler(this.AssociatedObject, OnDragQuery);
  RadDragAndDropManager.AddDragInfoHandler(this.AssociatedObject, OnDragInfo);
}

AssociatedObject_RowLoaded RowLoaded event handler
void AssociatedObject_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
  if (e.Row is GridViewHeaderRow || e.Row is GridViewNewRow || e.Row is GridViewFooterRow)
    return;
 
  GridViewRow row = e.Row as GridViewRow;
 
  if (row == null)
    return;
 
  row.SetValue(RadDragAndDropManager.AllowDragProperty, true);
  row.SetValue(RadDragAndDropManager.AllowDropProperty, true);
 
  RadDragAndDropManager.RemoveDropQueryHandler(row, OnGridViewRowDropQuery);
  RadDragAndDropManager.AddDropQueryHandler(row, OnGridViewRowDropQuery);
}
0
Accepted
Dimitrina
Telerik team
answered on 15 Nov 2013, 10:57 AM
Hello,

Indeed, the problem is that a notification for releasing the mouse button is never received by RadGridView. I am afraid that this is a Silverlight issue and we cannot do much about it. What I can suggest you is to try working with RadWindow instead of the MS MessageBox. Please check this online demo for an example.

Regards,
Didie
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
Corey
Top achievements
Rank 2
answered on 22 Nov 2013, 10:08 PM
That's unfortunate that it's an issue with Silverlight.  My dialogue actually uses a RadWindow, but thank you for the suggestion.  I managed to make a work-around by delaying the opening of the dialogue when the user double clicks by 100 ms.  I used a DispatcherTimer to do this and it seems to be a long enough delay for Silverlight to realize I'm not holding down the mouse button.  Thanks for the help.
Asked by
Corey
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Corey
Top achievements
Rank 2
Share this question
or