0

I'm implementing a full calendar IO custom view. I load the events via an API call, the number of events I get back is correct. But when calling the "callback(events)", fullcalendar implements a "range" filter on the data.

My problem I need to display all the “current day events” and below all future events of the “current day + 10”. But range filter is applied before rendering the "view", so I can only display a limited set of events and not customize it.

Is it possible to overwrite the default range filter and to implement my own? If so how and where is the class/function located?

Extra details: Fullcalendar IO version: 3.4.0 Code implementation:

$('#calendar').fullCalendar({
defaultView: 'cvDay2',
header: {
    left: '',
    center: 'prev title next',
    right: 'cvDay2 customAgendaWeek'
},
views: {
    customAgendaWeek: {
        eventLimit: 100,
        duration: {}

    },
    cvDay2: {
        eventLimit: 100
    }
},
displayEventTime: false,
titleFormat: 'D MMMM YYYY',
defaultDate: moment().startOf('isoWeek'),
slotEventOverlap: false,
firstDay: 1,
disableDragging: true,
navLinks: true, // can click day/week names to navigate views
editable: false,
eventLimit: 100, // allow "more" link when too many events
weekNumberCalculation: 'ISO',                  
events: function (start, end, timezone, callback) {

    app.CalendarService.getStoreSpecificCalendar(calendarServiceOptions)
        .done(function (events) {
            console.log(events); //array of 13 events is returned
            callback(events);
        }).fail(function () {
            window.location.href = errorPageUrl;
        }).always(function () {
        });
}});
Phoenix
  • 156
  • 10
  • "implements a "range" filter on the data.". I'm not aware of this, what "range" are you talking about? Dates? Of course it will only display events for the days which are part of the view. But you can configure how many days appear in an agenda view. Other than that I am not aware that the callback filters anything. Also, which of your two custom views are you referring to in terms of this issue? – ADyson Jan 05 '18 at 12:32
  • I have the issue in both views. The filter/range is comming from the "Duration" setting. This is currently 1 day(because I need the current day events) for cvDay2 view and 1 week for the customAgendaView. – Phoenix Jan 05 '18 at 12:36
  • So if you want 10 days of events, set it to 10 days in the agenda view. For a "day" view, by definition it always displays a single day. – ADyson Jan 05 '18 at 12:36
  • That is indeed what I tried, but then calendar view it self will display more then 7 days and I want a week view but in the "backend" it want 10 days of events – Phoenix Jan 05 '18 at 12:39
  • For what purpose, exactly? Why do you need 10 days of events if you're only going to display 7 of them? If you have a seven day view, and the user clicks to go to the next 7 days, fullCalendar will automatically call the events function again to fetch more data from the server. In the callback you'll see it provides you with the correct start and end dates to send to the server, so that it can send back the right info, although I notice in your code you are not using them in the call you make to your calendar service. – ADyson Jan 05 '18 at 12:42
  • The backend call is not fully there, I do use the range. But I need the 10 day event in the day view. Like I want the "Current day" event + all events of the next 10day to be displayed in that view. But the week view gets all event of the comming 10 day and then limits it to the "selected week". – Phoenix Jan 05 '18 at 12:46
  • there is no such thing as a "day" type of view...the available view types are "month", "agenda" and "list". The month view is fixed, so we can discount that. For the agenda and list view types, The fact it displays a single day is a function of the duration you set. In all other ways it is identical to a 7 day or 10 day view, or any other duration. – ADyson Jan 05 '18 at 12:49
  • As for _"the week view gets all event of the comming 10 day and then limits it to the "selected week" "._ If you are supplying the start/end range variables to your server, and it is processing them correctly (I don't know why you left this out of your code, it's misleading to publish code which isn't your real code, it distracts from finding the actual problem....), then the server should only be returning events which fall within that 7 day period. If it was working as intended it wouldn't return 10 days data. Even if it did do that, there's nowhere to display it, so fullCalendar ignores it – ADyson Jan 05 '18 at 12:52
  • BTW the custom view definitions in your code above are also invalid, and would not cause the views to be displayed - they are, at minimum, missing the "type" option. Please edit the question with your _real_ code, otherwise it's hard to diagnose the _real_ problem. – ADyson Jan 05 '18 at 12:56
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/162598/discussion-between-phoenix-and-adyson). – Phoenix Jan 05 '18 at 12:56
  • i am in the chat now – ADyson Jan 05 '18 at 12:59
  • @ADyson I found a solution, it is possible to access the 'unfiltered' object => eventClients() will return all events that are available in the "Events" object. – Phoenix Jan 05 '18 at 15:02

0 Answers0