EasyUI Forum
May 05, 2024, 08:45:23 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Simple drag&drop between treegrid/datagrid controls (no re-arrange)  (Read 10058 times)
tomb
Newbie
*
Posts: 14


View Profile
« on: August 12, 2014, 07:47:36 AM »

I looked at the two extensions to enable drag&drop to re-order/re-arrange items, but I have a use-case where I need to be able to essentially drag one item from a treegrid to a datagrid and vice versa, and I don't want any items to automatically be re-arranged, just notified when something was dropped.  I have all that mostly working with the extension, but I'm still getting the insert above/below markers, which in my use case don't make much sense.  Is there an easy way to prevent these markers?  I do use the re-arranging feature in another case, so I don't really want to disable it globally.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 12, 2014, 08:41:15 PM »

If you only want to drag rows to a datagrid, don't call 'enableDnd' method on the target datagrid, try the code below:
Code:
$('#dg2').datagrid('getPanel').find('div.datagrid-view').droppable({
accept: 'tr.datagrid-row',
onDragOver: function(e, source) {
var icon = $(source).draggable('proxy').find('span.tree-dnd-icon');
icon.removeClass('tree-dnd-yes tree-dnd-no').addClass('tree-dnd-yes');
},
onDragLeave: function(e, source) {
var icon = $(source).draggable('proxy').find('span.tree-dnd-icon');
icon.removeClass('tree-dnd-yes tree-dnd-no').addClass('tree-dnd-no');
},
onDrop: function(e, source){
//console.log(source)
}
})
Logged
tomb
Newbie
*
Posts: 14


View Profile
« Reply #2 on: August 13, 2014, 02:16:16 PM »

Hm, thanks!  However, I can't seem to get it to work, it seems to refuse dropping it.  I changed the accept property to accept:'tr[node-id]' (like it is in the treegrid-dnd extension), but that doesn't seem to help, either.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: August 13, 2014, 07:41:44 PM »

Please refer to the attached example 'test.html'. You can drag a treegrid row and append it to the datagrid component.
Logged
tomb
Newbie
*
Posts: 14


View Profile
« Reply #4 on: September 03, 2014, 03:00:38 PM »

Thanks, I got it to work, but it's not quite what I was trying to solve.  What I really need, is to be able to know over what item in the datagrid an item was dropped.  Also, I need to know where it was dragged from, as I have multiple trees/datagrids that have draggable stuff in them (although that would be more easily solvable by tagging items appropriately).

How can I find out which item is being dropped on?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!