0

I am using GXT for UI development. I have used HTML5 for Dragging file from Desktop to my application and upload it. But now i am having reverse requirement. I want to drag files from browser to desktop which will download the file to desktop.

I know that is possible in Chrome only. And had checked the below demo: http://www.thecssninja.com/javascript/gmail-dragout

I had tried to implement the above code in my GXT application, but the issue is that i am using Editable Grid which is supporting DnD to TreePanel. Now when i drag from grid to Desktop i think its not capturing the browser event (may be i am wrong here).

Any idea, how it should be done?

Thanks.

Below is the small piece of code which i call after the Data had been inserted in Grid. All records are having the CSS class name as ".icon". The problem is that when i start to drag, the "dragstart" is not being called. Any suggestion?

NOTE: This code is working when i create Buttons, Labels, etc and making them draggable=true with other required parameters.

 public static native void test(String id)/*-{
var files = $doc.querySelectorAll('.icon');
for (var i = 0, file; file = files[i]; ++i) {
    file.addEventListener("dragstart",function(evt){
        $wnd.alert("Drag Event started.. ");
        evt.dataTransfer.setData("DownloadURL",this.dataset.downloadurl);
    },false);
}

}-*/;

GingerHead
  • 8,130
  • 15
  • 59
  • 93
vbjain
  • 547
  • 2
  • 7
  • 23

1 Answers1

1

I used this, and it successully performs, no you should check some other place in your code.

GingerHead
  • 8,130
  • 15
  • 59
  • 93
  • harout, how you implement this on your gxt grid?i tried but i can't find way to handle gxt event + script event both to gather with the grid to perform downloading. you have any link or tutorial from where i can easily implements it? thanks – Dipesh Gandhi Apr 09 '12 at 07:11
  • Harout thanks for your comment. It will be good if you can let us know how this should be done. Or if you can share your piece of code then it will be much more helpful. Thanks. – vbjain Apr 09 '12 at 14:56
  • show me the piece of the code that handles this to advise, because I don't have the code with me right now – GingerHead Apr 09 '12 at 15:20
  • i just edited my post with small code, please see it and let me know if there is any suggestion. – vbjain Apr 11 '12 at 07:24
  • After so much debug i came to know that GRID using its Selection Model which is stopping the browser from firing the "dragStart" event. Can anyone let me know what should i write so Grid's DnD operation also keep working and native browser's "dragStart" event do fire? Or if i override the "DragStart" of GridDragSource, then i am getting event.getEvent().getDataTrasnfer() as NULL. Any idea why is it so? Any idea, how to get the getDataTrasnfer() of event not null. – vbjain Apr 14 '12 at 15:22
  • one question why are using javascript, use gwt's ordinary java code to handle your javascript – GingerHead Apr 14 '12 at 16:30
  • because if you call native javascript you may have some listeners' messing up. – GingerHead Apr 14 '12 at 16:32
  • DNDEvent dont have event.getNative()...can you let me know how i can get it? i didnt got your concern for native javascript? the above code is implemented through JSNI isnt it correct way? if not then can you tell how it should be done? – vbjain Apr 16 '12 at 12:21
  • com.extjs.gxt.ui.client.event.DNDEvent dont have event.getNative()...i have tried to check other alternatives too..but not getting the Native for it... – vbjain Apr 16 '12 at 14:30
  • DNDEvent has getDragEvent(), which, if not null, has a getEvent() call which will return the underlying JS event. – Colin Alworth Apr 19 '12 at 16:43
  • @Colin, from your way, e.getDragEvent().getEvent().getDataTransfer(), i am getting this null. :( – vbjain Apr 27 '12 at 10:39
  • If anybody interetsed in more detail i have posted this issue on GXT forums with sample code, http://www.sencha.com/forum/showthread.php?195424-Fire-native-quot-dragStart-quot-event-on-Grid-with-GXT-DragnDrop-are-also-enable-on-same-grid&p=779752#post779752 – vbjain Apr 27 '12 at 10:40