Page 1 of 1

Load range of events.

Posted: Mon Jul 27, 2020 10:54 pm
by Acalero

Hi,

I have a simple calendar panel like your mvvm example, the only difference is that our stores are type rest.

The problem is that it load all events, can I load only the events of the loaded view (day / week / month)?

And when press previous/next buttons load only the range of events appropriate?

Load all events in one request its crazy :S

Code: Select all

Ext.define('Cal.view.MainPanel', {
    extend : 'Cal.panel.Calendar',
    alias  : 'widget.mvvm-mainpanel',
    requires : ['Cal.view.MainPanelController','Cal.view.MainPanelModel'],

controller : 'mvvm-controller',
viewModel : {type : 'mvvm-viewmodel'},

title : 'MVVM Calendar',
date  : new Date(2019, 9, 14),
bind : {
    eventStore    : '{events}',
    resourceStore : '{calendars}'
}
});

ViewModel:

Ext.define('Cal.view.MainPanelModel',{
    extend : 'Ext.app.ViewModel',
    alias  : 'viewmodel.mvvm-viewmodel',

stores : {
    calendars : {
        type    : 'calendarresourcestore',
        storeId : 'resource',
        autoLoad:true,
        proxy: {
            type: 'rest',
            url: 'rest/calendar',
            reader: {type: 'json'}
        },
    },
    events    : {
        type    : 'calendareventstore',
        storeId : 'event',
        autoLoad:true,
        proxy: {
            type: 'rest',
            url: 'rest/events',
            reader: {type: 'json'}
        }
    }
}
});

thanks for your help.


Re: Load range of events.

Posted: Tue Jul 28, 2020 9:14 am
by Maxim Gorkovsky

Hello.
You'd need to listen to view change event and load event store passing additional params to the request. See this doc article: https://docs.sencha.com/extjs/7.1.0/classic/Ext.data.ProxyStore.html#method-load


Re: Load range of events.

Posted: Tue Jul 28, 2020 10:37 am
by Acalero

Hi,

Thank you for your feedback

Does prev./next/today buttons throw viewChange event?
Or do I need to add listeneres for every click button event and every change event? :S


Re: Load range of events.

Posted: Tue Jul 28, 2020 11:24 am
by Maxim Gorkovsky

Please refer to the doc. You can find number of events triggered by calendar panel there. You can try using this one: https://www.bryntum.com/docs/calendar-for-extjs/#!/api/Cal.panel.Calendar-event-beforemodechange