Load range of events.

Ask for help related to our Calendar 2.x version
Post Reply
User avatar
Acalero
Posts: 2
Joined: Wed Jul 08, 2020 8:03 pm

Load range of events.

Post 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.


User avatar
Maxim Gorkovsky
Core Developer
Core Developer
Posts: 3251
Joined: Wed Jan 08, 2014 11:46 am

Re: Load range of events.

Post 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


User avatar
Acalero
Posts: 2
Joined: Wed Jul 08, 2020 8:03 pm

Re: Load range of events.

Post 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


User avatar
Maxim Gorkovsky
Core Developer
Core Developer
Posts: 3251
Joined: Wed Jan 08, 2014 11:46 am

Re: Load range of events.

Post 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


Post Reply