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

How to disable dragdrop when editing cell

2 Answers 145 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Valerie
Top achievements
Rank 1
Valerie asked on 26 Mar 2013, 08:57 PM
If I am in edit mode and try to select the text with my mouse it thinks I am dragging that row. I tried to disable this with this code but it had no effect.

                <Style TargetType="telerik:GridViewCell" >
                    <Style.Triggers>
                        <Trigger Property="IsInEditMode" Value="True">
                            <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="False"></Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>

I then added code to OnDragInitialize in my DragDropBehavior attached behavior that returns if the current cell is in edit mode. It does stop the drag from happening but it also interferes with the user from selecting the string. It stops after the first character and changes the cursor to an arrow.

        private void OnDragInitialize(object sender, DragInitializeEventArgs e)<br>        {<br><div><span style="font-size: 11px; line-height: 1.4;">            var radGridClientObject = sender as RadGridView;</span><br></div>            if (radGridClientObject != null)<br>            {<br>                if (radGridClientObject.CurrentCell.IsInEditMode)<br>                {<br>                    return;<br>                }<br>            }<br><div></div>

How can I disable drag/drop when in edit mode?
Thanks, Valerie

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 27 Mar 2013, 09:03 AM
Hello Valerie,

I can speculate that you have subscribed for the DragInitialize event with handledEventsToo set to true, considering the behavior you are experiencing. Is that correct? 

You can stop the Drag operation in the DragInitialize handler by setting the e.Cancel to true. 

Let me know if that works! 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Valerie
Top achievements
Rank 1
answered on 27 Mar 2013, 02:10 PM
Thanks Nik, that was it! The cancel worked perfectly.
Tags
DragAndDrop
Asked by
Valerie
Top achievements
Rank 1
Answers by
Nick
Telerik team
Valerie
Top achievements
Rank 1
Share this question
or