EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: alastairwalker on August 16, 2014, 08:39:53 AM



Title: How to disable drags and drops within treegrid?
Post by: alastairwalker on August 16, 2014, 08:39:53 AM
I am trying out the example in http://www.jeasyui.com/extension/treegrid_dnd.php for d and d between the treegrid and datagrid.

The functionality I need must disable the d and d within the treegrid.

I want to restrict the functionality to:
a) select a row from the treegrid;
b) to only allow a drop on the datagrid.

How do I go about this?

I searched the posts, but could not locate how to do this.

Many thanks in anticipation..

Alastair


Title: Re: How to disable drags and drops within treegrid?
Post by: stworthy on August 17, 2014, 06:02:10 AM
To disable dropping nodes on the treegrid, please try the code below:
Code:
$('#tg').treegrid({
onDragEnter: function(targetRow,sourceRow){
var opts = $(this).treegrid('options');
var tr = opts.finder.getTr(this, targetRow[opts.idField]);
if (tr.attr('node-id')){
return false;
}
}
})


Title: Re: How to disable drags and drops within treegrid?
Post by: alastairwalker on August 18, 2014, 05:36:33 AM
Many thanks!

For the record, this is the script I had to actually use:

$(function(){$('#tg').treegrid({onDragEnter: function(targetRow,sourceRow)
   {
   var opts = $(this).treegrid('options');
   var tr = opts.finder.getTr(this, targetRow[opts.idField]);
   if (tr.attr('node-id')){return false;}
   }})
});

(Note: the parentheses were unbalanced.)

Alastair