Support Forum
Hi!
This demo uses it's own Drag implementation in lib/Drag.js.
Try replacing onTaskDrag method there with this code to respect allowOverlap.
This demo uses it's own Drag implementation in lib/Drag.js.
Try replacing onTaskDrag method there with this code to respect allowOverlap.
onTaskDrag({ event, context }) {
const
me = this,
{ schedule } = me,
coordinate = DomHelper[`getTranslate${me.schedule.isHorizontal ? 'X' : 'Y'}`](context.element),
startDate = schedule.getDateFromCoordinate(coordinate, 'round', false),
endDate = startDate && DateHelper.add(startDate, context.task.duration, 'h'),
// Coordinates required when used in vertical mode, since it does not use actual columns
resource = context.target && me.schedule.resolveResourceRecord(context.target, [event.offsetX, event.offsetY]);
// Don't allow drops anywhere, only allow drops if the drop is on the timeaxis and on top of a Resource
// Also respect allowOverlap scheduler setting
context.valid = context.valid &&
Boolean(startDate && resource && endDate) &&
(schedule.allowOverlap || schedule.isDateRangeAvailable(startDate, endDate, context.task, resource));
// Save reference to resource so we can use it in onTaskDrop
context.resource = resource;
}
Replaced existing code with this, but it doesn't seem to be working as expected.
When drag / dropping from the event scheduler itself the items just start being presented underneath each other.
Tried turning the: autoRescheduleTasks feature on and off which had no impact on the results.
Orientation of the scheduler is horizontal, unsure if this important for this code.
When drag / dropping from the event scheduler itself the items just start being presented underneath each other.
Tried turning the: autoRescheduleTasks feature on and off which had no impact on the results.
Orientation of the scheduler is horizontal, unsure if this important for this code.
Finally took some time to update to the latest version and anonymize the data I'm working with to show the example.
I hope this will clarify what is going wrong.
Another thing I didn't specify earlier but now that I've implemented the resource grouping I also want to prohibit the dropping of the task on the group headers.
I presume this should be almost the same logic.
I hope this will clarify what is going wrong.
Another thing I didn't specify earlier but now that I've implemented the resource grouping I also want to prohibit the dropping of the task on the group headers.
I presume this should be almost the same logic.
- Attachments
-
- schedule_drag_from_grid.zip
- (10.72 KiB) Downloaded 140 times
allowOverlap is a config which should be applied to scheduler. Just move the config from features to scheduler, and it will work:
schedule = new Schedule({
allowOverlap : false, // ADD HERE
ref : 'schedule',
insertFirst : 'main',
features : {
stripe: true,
quickFind: true,
//nonWorkingTime: true,
columnReorder: false,
recurringTimeSpans : {
store : timeRangeStore
},
timeRanges : {
// use our store for time ranges
store : timeRangeStore,
showCurrentTimeLine : true,
showHeaderElements : true
},
// allowOverlap : false, // REMOVE HERE
Pavlo Miklashevych
Sr. Frontend Developer
Awesome thank you !!
This solves the problem for drag and drop within the schedule.
Do you also have a solution for the not being able to drop in the group header from the Grid?
This also seems to be working correctly in the schedule itself.
This solves the problem for drag and drop within the schedule.
Do you also have a solution for the not being able to drop in the group header from the Grid?
This also seems to be working correctly in the schedule itself.
Last edited by wboard on Sat Apr 18, 2020 5:15 pm, edited 1 time in total.