search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Display Totals On Rows and Columns

Asked by Aliaa
5 years ago.

Hi Dan,

I am trying to display total hours on rows and columns of the scheduler. The way I am doing this is by calculating totals and then using jQuery to display values on row and columns headers in OnAfterRender and after any update. This works fine until I scroll horizontally or vertically the value is reset (this happens after scrolling for some time not right away). It seems that after scrolling, the row/column headers are redrawn but I do not think that onBeforeResHeaderRender or onBeforeTimeHeaderRender are called. I thought about using onScoll but it only works with dynamicLoading.

Calculating the totals in onBeforeResHeaderRender doesn't help because when the scheduler is first being created the resources are loaded then events. Meaning that there are no events and the total is zero. So, even though values are displayed in onAfterRender, after scrolling the value would be reset.

My question is, what is the best event handler to place the totals display logic?

Comment posted by Aliaa
5 years ago.
Answer posted by Dan Letecky [DayPilot]
5 years ago.

Hi Aliaa,

Sorry for the delay.

There are actually two event handlers that let you customize the row headers:

1. The onBeforeResHeaderRender is a legacy event which is only fired when the rows are loaded from the resources[] array:
https://api.daypilot.org/daypilot-scheduler-onbeforeresheaderrender/

2. There is also onBeforeRowHeaderRender which is fired when the row headers are actually rendered. At that moment the row event data is already available. It can be also fired multiple times (whenever the row is rendered when progressive rendering is enabled):
https://api.daypilot.org/daypilot-scheduler-onbeforerowheaderrender/

This approach is used in the Timesheet tutorials to count the row totals:
https://code.daypilot.org/46581/html5-timesheet-javascript-php

The time headers are rendered all at once (not progressively) and they are not affected by scrolling.

Please let me know if it doesn't help.

Comment posted by Aliaa
5 years ago.

Thanks Dan. Using onBeforeRowHeaderRender fixed the issue for row totals. I am still having a problem with column totals. I will further investigate this. Thanks again.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.