Page 1 of 1

[INFO REQ] [REACT] How to use preindexed data

Posted: Fri Sep 23, 2022 12:25 pm
by tamas.cserveny

Hi,

We would like to feed the scheduler pro component with data loaded on demand from a server backend. The dataset is large, we cannot put everything on the client. We have around 1600 resources and around 4000 events each per year.

We have single assignment and the data is coming in a pre-indexed format. Adding event to a event store will run dayindex over them again. Is there a possibility to use our index for the lookup and skip day index?

Is it possible to create an event store with different mixins and replace GetEvents and DayIndex? Is it a supported use case?

Cheers,

Tamás


Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Fri Sep 23, 2022 7:32 pm
by marcio

Hey Tamás,

Yes, you can have a custom event store with custom methods to override as you need, we have some examples in our demos, but a sample would be

/**
 * Custom Task Store
 *
 * Taken from the vanilla dragfromgrid example
 */
import {  EventStore } from '@bryntum/scheduler';

import Task from './Task';

export default class CustomStore extends EventStore {
    // Example of custom default configuration
    static get defaultConfig() {
        return {
            modelClass : Task
        };
    }

afterLoadData() {
    // Rewrite your custom config for this
}
}

And then, on your configuration, you can set

    crudManager: {
        eventStore: {
            storeClass: CustomStore
        },

}

Please check the documentation here for more info https://www.bryntum.com/docs/scheduler-pro/api/Scheduler/data/CrudManager#config-eventStore


Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Mon Sep 26, 2022 4:13 pm
by tamas.cserveny

Is it possible to extend SchedulerBasicEvent as basis of our event?

The Pro event contains many things like calculation of earlyStartDateConstraintIntervals etc...
Or when I would overwrite the afterLoadData method, those calculations would not run?

How can I instantiate a model class correctly? Until now we just added JS object into the EventStore like:

eventStore.add([{id: 1, startDate: new Date(), ....}, ...]);

Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Tue Sep 27, 2022 2:54 pm
by marcio

Hey,

Yes, it's possible, most of the classes in Bryntum's suite are extensible.

If you overwrite the method without calling the super method, everything that was coded inside the afterLoadData method won't be executed.

You can set it up just like a plain JS class, there is no secret in our implementation. We have a guide for it here https://www.bryntum.com/docs/scheduler/guide/Core/advanced/classes


Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Tue Sep 27, 2022 2:57 pm
by tamas.cserveny

How can I disable calculations like "earlyStartDateConstraintIntervals" or "dependency"?

Is it possible to use the simple schedule event model for pro? I did not found the import for it.


Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Tue Sep 27, 2022 3:52 pm
by arcady

Basic model is not meant to work in Pro. It was never tested and thus most probably there will be exceptions when reading some missing fields.

You can try using your custom event model classes of course. Here is for example I make a class equivalent to standard Scheduler EventModel class:

class MyEvent extends SchedulerBasicEvent.derive(TimeSpan).mixin(
    RecurringTimeSpan,
    PartOfProject,
    EventModelMixin,
    CalendarCompatMixin
) {}

const scheduler = new SchedulerPro({
    project : {
        // use my custom event model
        eventModelClass : MyEvent,

You can also override calculateEarlyStartDateConstraintIntervals method which is used to build that field value:

class MyCustomEvent extends EventModel {

    * calculateEarlyStartDateConstraintIntervals () {
        return []
    }

}

Re: [INFO REQ] [REACT] How to use preindexed data

Posted: Tue Sep 27, 2022 4:01 pm
by tamas.cserveny

Thank, I'll try the 2nd variant, that looks more managable.