Our pure JavaScript Scheduler component


Post by Srindt »

Hi mats,

I have attached my project.

You can have a look at App.vue @ line 140.This is where, I have the afterEventDrop listener, where I'm setting resourceName.

This is a modified example of drag-onto-tasks vue example.

I have also attached another zip, where-in each pic represents the resourceName at each row,
when dragged.

a.When an event is first created, it is set to string Default. So when event is dragged from one row to the other, it sets the previous resourceName only.

b.When it is dragged in the same row, it shows the corresponding correct resourceName.(but for the first drag, it didn't work for me).

So kindly have a look at the code and the attached pics for your reference.

Attachments
resourceName-drag-pics.zip
(119.15 KiB) Downloaded 76 times
drag-onto-tasks_resourceName.zip
(1.09 MiB) Downloaded 111 times

Post by alex.l »

Hi Srindt,

All you need is to extend your event model with resourceName field you used, as Mats suggested.

/**
 *- Custom Task model
 *
 * taken from the vanilla example
 */
import { SchedulerEventModel } from 'bryntum-schedulerpro';

export default class Task extends SchedulerEventModel {
    static get defaults() {
        return {
            // in this demo, default duration for tasks will be hours (instead of days)
            durationUnit : 'h',
            equipment    : []
        };
    }

static get fields() {
    return [
        'resourceName'
    ];
}
}
schedule.on('afterEventDrop', ({ eventRecords, source, context }) => {
        let newResourceName = eventRecords[0].resource.name;
        eventRecords[0].resourceName = newResourceName;
    }
    });
}

I checked in the app you attached, it works!

All best,
Alex

All the best,
Alex


Post by Srindt »

Thanks for the update alex.

It is working !

But could u kindly explain, why we need to return 'resourceName' from fields (in Task class) ?

Because, I see time getting updated properly when dragged.

Does it mean, if I want to dynamically change property myself( not by framework automatically),I need
to return those modifiable attributes from fields (in Task class)?


Post by pmiklashevich »

Hello,

Please check out the docs of the Model class: https://www.bryntum.com/docs/scheduler/#Core/data/Model

why we need to return 'resourceName' from fields

You define a new field this way. Fields can be automatically exposed from your data, but then 'resourceName' should be defined in the first record you load to the store. Otherwise it will be missing and setting to the field will not be possible. Usually we recommend to describe your fields explicitly.

Best,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by Srindt »

Thank you !!


Post Reply