No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Hoping for input on calendar usecase

    Hi, i was hoping that you guys, who know the in and outs way better than me could share thoughts on a client use case:

    We use a calendar, with days on x-axis and users on y-axis. Clients can for example use it to plan time slotting for a restaurant or similar.

    One thing that's come up is that it's hard to see how much time that has been allocated for a person for the time interval showing in the calendar.

    I suppose that the raw use case is basically:

    1. A hook into when the calendar has finished loaded all data (which can be multiple dsrequests depending on the amount of events, obviously)
    2. Iterate through every lane and calulate the total time for all CalendarEvent in that lane
    3. dynamically set the Lane title based on the Record for that lane and the calculated time

    So, my question is simply if this is at all feasible to do? Would be great with some input.

    The way to do this is to override Calendar.eventsRendered() and use Calendar.getLaneEvents(lane) to grab the events you're interested in, to calculate your new titles - and, of course, apply them as the titles of the existing lanes - however:

    1) the eventsRendered() notification was not exposed with an EventHandler in SGWT

    2) there was no public API like Calendar.setLaneTitle(String lane, String title), which updated in-place without other refreshing or redrawing

    We've added both to 13.0+ - please retest with tomorrow's build.


      Wow, thats great news. Top-notch quick response too, i'm impressed. This will be handy for us - thanks!


        Hi there, now getting around to implementing this! I have a few issues:

        1. In my custom Timeline class, i have a setup-method called when it is being initialized:
        public void loadLanes(){
                Criteria crit = new Criteria();
                    crit.setAttribute("enabled", true);
                laneDS.fetchData(crit, (dsResponse, o, dsRequest) -> {
                    Record[] data = dsResponse.getData();
                    Lane[] lanes = new Lane[dsResponse.getData().length];
                    for (int i = 0; i < data.length; i++) {
                        lanes[i] = new Lane(data[i].getAttribute("id"), data[i].getAttribute(laneNameField));
                        lanes[i].setAttribute(laneNameField, data[i].getAttribute(laneNameField));
        I notice that the eventsRenderedHandler gets called twice - once when the lanes have loaded (i guess because of "setLanes"), and then again after the fetchData is complete.

        Is this by design? Because when you change the lanes you want to (re)-render the events? Is there a way to set the lanes without re-rerendering?

        2. The handler gets called a lot, not only when data has finished loading as i described above. Every time i scroll inside the timeline it gets called too. This makes it lag and as mentioned is not what i'd like.

        3. Are you sure that the "setLaneTitle(String lane, String title)" does not redraw the entire calendar? I notice that it was noticably slow to update when i iterated through the lanes and called it for every method. Instead opting to call just Lane.setTItle for all lanes, and Then did Timeline.redraw() when i was finished wth all lanes was *much* faster.

        4. The handler also gets called every time a CalendarEvent has a CRUD operation. This means that all events in all lanes gets recalculated, when only one lane needs to be examined.


        All these points is because i really want the handler not to be called when not needed - going through all events for all lanes when nothing has changed is costly and makes the browser lag.

        Last edited by mathias; 9 Feb 2022, 07:21.


          Calendar.setLanes() actually has a second parameter, skipRefreshEvents - but there's no SGWT signature that accepts it. We'll add one shortly.

          On the other points you added later (we only get notifications for new posts, not edits), about the frequency of eventsRendered() - yes, it runs from refreshVisibleEvents(), which may happen on scroll and in various other circumstances.

          We'll look into perhaps adding a separate notification with a less frequent foot-print, and we'll also take a look at the lane-change and CRUD -based redraws you mention.

          All of these are queued, so we'll update here when they get attention.
          Last edited by Isomorphic; 13 Feb 2022, 08:06.


            A quick follow up here - can you confirm what sort of timeline you have? Range (and column-count), lane-count, databinding-setup, etc.

            If you can provide some standalone code that shows the problems, we'll likely get to it more quickly.


              Hi thanks for responding.

              For granularity, we allow the clients to choose from a couple, but the most common is days, where we show 4 weeks (i.e. a month) at once. The lanes depend too depending on the size of the client, but it can be hundreds.
              In my testing right now however, i only have around 20 lanes.

              Not sure what info you're looking for regarding datasource, but it's a regular ds with foreign keys into two other, one of which is used for the lanes. Happy to provide more details.