Our pure JavaScript Scheduler component


Post by stan92 »

Hi,

Like events, I wonder if it would be possible to add reccurences for resourceTimeRangesFeature items and even for timeranges?
I tried
     
id: 1, resourceId: "xxx", startDate: '2019-12-12T10:00', endDate: '2019-12-12T17:00', timeRangeColor: 'red',recurrenceRule: "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR"
Also, what would be the best practice to load events based on the displayed range dates of the sheduler?

Thanks

Post by arcady »

Allowing an arbitrary store to contain recurring timespans will appear in the upcoming Scheduler 3.0 release. We plan to release it this week.

There was a similar question on the forum where I provided a solution w/ a couple of temporary workarounds: viewtopic.php?f=51&t=12640&p=67581#p66379

After the upcoming Scheduler 3.0.0 release the code posted there will still be valid except the pieces marked with "WORKAROUND:" string won't be needed.

Post by arcady »

stan92 wrote: Wed Dec 18, 2019 8:50 am Also, what would be the best practice to load events based on the displayed range dates of the sheduler?
Regarding this, an application could track the Scheduler time range by listening to its timeAxisChange event and reload store if the range gets changed. In this case time range start/end should be passed to the server so it could pick proper records to return..

Post by stan92 »

arcady wrote: Wed Dec 18, 2019 10:36 am Allowing an arbitrary store to contain recurring timespans will appear in the upcoming Scheduler 3.0 release. We plan to release it this week.

There was a similar question on the forum where I provided a solution w/ a couple of temporary workarounds: viewtopic.php?f=51&t=12640&p=67581#p66379

After the upcoming Scheduler 3.0.0 release the code posted there will still be valid except the pieces marked with "WORKAROUND:" string won't be needed.
I thank you Arcady, but I can't read the post (You are not authorised to read this forum) :-(

Post by mats »

Here's the code of that post:
// Here we make a new Model extending TimeSpan class with RecurringTimeSpan mixin (which adds support of recurrence to a model)
class MyTimeRange extends RecurringTimeSpan(TimeSpan) {

    // WORKAROUND: This method override won't be needed after the next release
    get occurrences() {
        const store = this.stores[0];

        return store && store.getOccurrencesForTimeSpans && store.getOccurrencesForTimeSpans(this);
    }

    // WORKAROUND: This method override won't be needed after the next release
    removeOccurrences() {
        const store = this.stores[0];

        return store && store.removeOccurrencesForTimeSpans && store.removeOccurrencesForTimeSpans(this);
    }
};

// Here we make a new store class extending Store with RecurringTimeSpansMixin mixin (that adds recurrence support to a store).
// That class will use our new MyTimeRange model.
// This store will contain time ranges.
class MyStore extends RecurringTimeSpansMixin(Store) {

    static get defaultConfig() {
        return {
            modelClass : MyTimeRange,
            storeId    : 'timeRanges'
        };
    }

    construct(config) {
        super.construct(config, true);
        // setup recurrence support
        this.setupRecurringTimeSpans();
    }
};

// instantiate store for time ranges using our new classes
const timeRangesStore = new MyStore();

// WORKAROUND: Make new feature extending existing RecurringTimeSpans. This won't be needed after the next release.
class MyRecurringTimeSpans extends RecurringTimeSpans {
    static get $name() {
        return 'RecurringTimeSpans';
    }
};
// WORKAROUND: Register our feature. This won't be needed after the next release.
GridFeatureManager.registerFeature(MyRecurringTimeSpans, false, 'Scheduler');

scheduler = new Scheduler({
    adopt      : 'container',
    minHeight  : '20em',
    eventStyle : 'colored',

    features : {
        stripe               : true,
        // add recurringTimeSpans feature processing timeRangesStore store
        recurringTimeSpans : {
            store : timeRangesStore
        },
        timeRanges : {
            // tell timeRanges feature to use the store we made
            store               : timeRangesStore,
            enableResizing      : true,
            showCurrentTimeLine : true,
            showHeaderElements  : true
        }
    },
....

Post by Takaner »

mats wrote: Wed Dec 18, 2019 8:25 pm Here's the code of that post:
.......
What would be now the implementation in v3.0.0?

Post by sergey.maltsev »

Hi, Takaner!
you can see comment above
After the upcoming Scheduler 3.0.0 release the code posted there will still be valid except the pieces marked with "WORKAROUND:" string won't be needed.
If you still have questions please create a new post with problem description and sample code or app attached which we can check to give you help.

Some tips on how to ask for help.

Post Reply