Showing Validation Messages In Ext Scheduler

Recently we added support for showing custom validation messages inside the drag-drop, resize, and drag-create tooltips. This makes it easier for you as developers to enhance the user experience when an action is not allowed. Instead of just showing an icon that an action is unavailable, you can inform the end users of why. Let’s say some of your resources must be booked for a minimum of two days, you could now add that check easily like this:

createValidatorFn : function (resourceRecord, start, end) {
    if (resourceRecord.get('Category') === 'Robots' && Sch.util.Date.getDurationInDays(start, end) < 2) {
        return {
            valid   : false,
            message : 'Robots must be booked for at least two days'

Now, if you try to create a new task with a duration less than two days, a message will be shown in the tooltip as seen below:

Screen Shot 2015-03-12 at 12.12.10

Previously your validator methods could only return true or false but as you see above, the new API allows for an object to be returned as well. The same concept applies to drag-drop validation and resize validation, and you can try this out right now in the ‘validation’ sample.

Happy hacking!

Leave a Reply

Notify of