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

Turn Off Drag/Drop From Code-behind

2 Answers 59 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 20 Aug 2013, 09:04 PM
Hi!

I have a case where I want to disable Drag and Drop based on whether the user is accessing my site from a laptop or mobile device.  If it's Mobile, I want to disable it.

I thought that the OnInit event would be the right place to do this.  Could someone point me in the right direction for this?

TIA!
protected void ItemTree_Init(object sender, EventArgs e)
{
    var browsersniff = Request.Browser;
        if (browsersniff.IsMobileDevice == true)
        {
            this.ItemTree.EnableDragAndDrop = false;
            this.ItemTree.EnableDragAndDropBetweenNodes = false;
        }
}

       

 (Edit: I should add that the code above does get hit when I run on the debugger.  It just isn't disabling Drag/Drop)

 

2 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 23 Aug 2013, 06:27 AM
Hello Richard,

I've tested the described scenario, but it worked fine on my end. I've attached the sample page I used. Could you run it on your end and see if the issue reproduces? If the page is missing some important part of your project that's needed for reproducing the issue, please modify it accordingly and send back the modified code, so that we can inspect it locally.

Could you also specify what mobile device you are using for testing?
 

Regards,
Bozhidar
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Richard
Top achievements
Rank 1
answered on 23 Aug 2013, 10:57 AM
Thank you for this...

Our page is way, way more complicated than that.  :-)  But, since your example worked, I think it's something in our initialization code someplace else that might be causing this issue.

I decided to try in our OnTreeLoad javascript handler and I was successful (code below).

For the most part - our users carry iPads, but we want to disable Drag/drop for all mobile device users.  We are testing with the iPad and Kindle HD.

Thanks for your help!

if ("<%=ismobile %>" == "True") {
    sender.set_enableDragAndDrop(false);
    sender.set_enableDragAndDropBetweenNodes(false);
}
Tags
TreeView
Asked by
Richard
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Richard
Top achievements
Rank 1
Share this question
or