Is there an event that can be hooked in to when the calendar initiates a query?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I am displaying multiple users on a single calendar and given the volume the query could take some time to display. On initial load I can control the first query and display a wait message to the user so they don't think the screen is locked up or not working. 

Is there a way to hook into an event that is triggered when the calendar does a re-query so that I can display a wait message?
Photo of John De Santiago

John De Santiago

  • 736 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
I think putting a model action on the model that the calendar is based on should do the trick.  Just create a new model action and use the "Model Requeried" Initiating Event.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Oh wait, that might happen after the query is done.  I'll have to think about this a bit more.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Ok, this isn't officially supported, and we should probably create a more formal event for handling this, but the following code should work as an "In-Line" javascript resource.

var defaultCalendarEvent = skuid.calendar.Calendar.prototype.loadEvents;
skuid.calendar.Calendar.prototype.loadEvents = function() {
    console.log('Before Load!!!!');
    defaultCalendarEvent.apply(this);
    
};
Photo of John De Santiago

John De Santiago

  • 736 Points 500 badge 2x thumb
Thanks Ben. That does work for executing before calendar loads but my next hurdle is that the event returns immediately which means I can't display a loading message for the duration that the query is executing. Unless there is some callback option in the method I can take advantage of. 
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Yeah, then you'd need to do this...

var defaultLoadEvent = skuid.calendar.Calendar.prototype.loadEvents;skuid.calendar.Calendar.prototype.loadEvents = function() {
    console.log('Before Load!!!!');
    defaultLoadEvent.apply(this);
};
var defaultDrawEvent = skuid.calendar.Calendar.prototype.drawEvents;
skuid.calendar.Calendar.prototype.drawEvents = function() {
    console.log('Before Draw!!!!');
    defaultDrawEvent.apply(this);
    console.log('After Draw!!!!');
};
Photo of John De Santiago

John De Santiago

  • 736 Points 500 badge 2x thumb
Thanks! That works like a charm.