EasyUI Forum
May 01, 2024, 04:38:50 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Drag and Drop Treegrid (dynamically expand nodes)  (Read 5432 times)
siccak
Newbie
*
Posts: 5


View Profile Email
« on: August 23, 2016, 01:49:19 PM »

Hello,

I am using treegrid with data from remote server via url attribute.

And this is what I am trying to achieve:

Code:
tg.treegrid({
  onLoadSuccess: (row) ->
    tg.treegrid('enableDnd', if row then row.id else null)
  onDragEnter: (targetRow, sourceRow) ->
    delay 2000, ->
      if tg.parent().find('.datagrid-row-over').attr('node-id') == targetRow.id
        tg.treegrid('expand', targetRow.id)
})

During drag phase I am trying to dynamically expand my treegrid nodes (using onDragEnter for this as shown above).

The problem is that onDragEnter event is fired only for initial nodes (before any expand). All nodes which are shown after expand event does not fire onDragEnter event.

Maybe this is not the correct way how to achieve this, but maybe someone can help me.

Thanks, Sicco
« Last Edit: August 23, 2016, 02:05:17 PM by siccak » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: August 23, 2016, 06:50:40 PM »

You can call 'resetDnd' method to fix this issue. Please download the 'treegrid-dnd.js' file from http://www.jeasyui.com/extension/treegrid_dnd.php

Code:
$('#tg').treegrid({
onLoadSuccess: function(row){
$(this).treegrid('enableDnd', row?row.id:null);
},
onExpand: function(){
$(this).treegrid('resetDnd');
},
onDragEnter: function(targetRow, sourceRow){
$(this).treegrid('expand', targetRow.id);
}
});
Logged
siccak
Newbie
*
Posts: 5


View Profile Email
« Reply #2 on: August 23, 2016, 11:37:00 PM »

Hello Jarry,

it works, thank you very much.

Sicco
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!