Our pure JavaScript Scheduler component


Post by MichaelZhu »

Hi,

I'd like to prevent some event to be dragged based on some conditions.

      eventDrag: {
        constrainDragToResource: false,
        validatorFn: this.dragValidator
      },
      ...
      dragValidator(context) {
      if (context.record.event.scheduleType === 0) {
                  this.$api.production
            .canDrag(context.record.event.itemNo, context.newResource.name)
            .then(res => {
              return res;
            });
      } else {
        ...
        }
        return true;
      }
    },

How to do it based on a restful API result?

Regards


Post by alex.l »

Hi MichaelZhu,

This method is sync and cannot use promises as a result.
Our approach allows to do validation before drag (only sync) and async validation on https://bryntum.com/docs/scheduler/#Scheduler/feature/EventDrag#event-beforeEventDropFinalize
Otherwise it is not clear what to do with drag operation while async validation in progress.
I can suggest you try to change your solution a bit to be sync (if possible) and as example, use some extra flag for the event record to decide if this event is draggable or not and check that flag in validatorFn.
Or maybe try to do https://bryntum.com/docs/scheduler/#Core/util/drag/DragContext#function-abort in validatiorFn in case you promise returns no valid.

All the best,
Alex

All the best,
Alex


Post Reply