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

onBeforeTimeHeaderRender is being run for every event when using gantt

Asked by Viktor Eriksson
10 years ago.

I have my scheduler with viewType = "Resources".
I add my events and run dps.update().
onBeforeTimeHeaderRender runs 11 times.
But when switching to viewType = "Gantt" it runs 11x#events times every time I update.
So if I have 16 events it will run 16x11 = 198 times.
Maybe I am using it wrong.

Here is a fiddle: http://jsfiddle.net/Yja42/2/
To test:
It will load with viewType = "Resources".
Try clicking Reload events button.
The log will output 11 at the bottom.
Try switching to gantt and press the same button.
It will now say 198.

(I'm pretty sure I have gotten this behaviour when using viewType = "Resources" as well but I havnt been able to recreate it yet)

Side question. How do I add events in the fastest way ?

Comment posted by Viktor Eriksson
10 years ago.

The extra .update() when clicking the button is unnecessary I guess.
Does each events.add call re-render all timeheaders ?

Answer posted by Dan Letecky [DayPilot]
10 years ago.

The answer is related to you side question: "How do I add events in the fastest way ?"

The fastest way is to use .events.list and .update():

dps.events.list = [{...}, {...}];
dps.update();

The .events.add() and related methods (.events.remove() and .events.update()) add the event to .events.list and call .update() internally.

Every .update() refreshes the scheduler and invokes the rendering events (onBeforeEventRender, onBeforeCellRender, onBeforeResHeader, onBeforeTimeHeaderRender).

See also:
http://doc.daypilot.org/scheduler/event-loading/

Comment posted by Viktor Eriksson
10 years ago.

I have tried now to manipulate the dps.events.list instead. But I get an exception.
Uncaught date parameter is not a Date object: function ($0M){if(typeof $0M==='undefined'){return new DayPilot.Date(e.data.start);}else{this.temp().start=new DayPilot.Date($0M);}}

In the example in the documentation you send in the date as a string for some reason, I assume it doesnt Have to be a string. Tried string anyway just to test but same problem. Can you see what is wrong ?

Here is the updated fiddle:
http://jsfiddle.net/Viktor/Yja42/5/

Comment posted by Viktor Eriksson
10 years ago.

oooh I see now, the list doesn't contain daypilot events but some arbitrary object instead.

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