DnD - constraints for target

Hello,

  1. Is it possible to show available target places during dragging?

E.g. root node is not possible to drag under another root node, but ui doesn’t disable it for user. User trying drag, but behaviour is not expectable.
(example here: docs.dhtmlx.com/gantt/samples/07 … ering.html)

Is it possible define rules which targets are available?

  1. Is it possible to cancel dragging operation if target is not suitable?
    I tried to check target in the event ‘onRowDragEnd’ and return false, but dragging is finished ok

Thanks for any help.

Hello,
you can color the rows using a css template function
docs.dhtmlx.com/gantt/api__gantt … plate.html
E.g.
CSS:.cant-drop{ background: #e8e8e8 !important; border-color: #e8e8e8; color: #adadad; }
JS:[code](function(){
var drag_id = null;
gantt.attachEvent(“onRowDragStart”, function(id, target, e) {
drag_id = id;
return true;
});
gantt.attachEvent(“onRowDragEnd”, function(id, target) {
drag_id = null;
gantt.render();
});

gantt.templates.grid_row_class = function(start, end, task){
	if(drag_id && task.id != drag_id){
		if(task.$level != gantt.getTask(drag_id).$level)
			return "cant-drop";
	}
	return "";
};

})();[/code]

Currently there is no blockable event for canceling reordering

Hello Aliaksandr, thanks a lot for feedback

I have tried the code upeer, but I got the error ‘ReferenceError: curr_id is not defined’

Could you please help with it?

Hi,
sorry, my mistake. There should be ‘drag_id’ instead of ‘curr_id’. I’ve updated the code snippet

Thanks, now it works fine!