Tips ‘n Tricks: Rendering Meta Data In The Timeline Header

Today we released new versions of Ext Scheduler and Ext Gantt. As part of the new scheduler release, we updated two of the examples to show off some cool header rendering tricks. In our mail inbox, one common question we get is “How do I render a summary in the timeline header?”. This question can now be easily answered by checking out these samples.

Rendering text into the timeline header

Screen Shot 2014-05-05 at 16.12.22

Let’s say you want to show some type of summary showing how many tasks exist for each day in the schedule. To do this, all you have to do is to create a custom view preset and devote the bottom row to rendering your summary. Here’s how you create and register a new custom preset which produces the output in the image above (from the updated ‘timeaxis‘ sample):

As of the latest release, you now have access to the eventStore of the panel where the header is being rendered. This makes it really easy to do summaries like this. As you can see in the code snippet above, all we do is to query the eventStore based on the header cell start/end dates.

Rendering event bars into the timeline header

We recently had a request to draw event bars in the header. This requires a little more work but is still really simple to achieve. Here’s an image showing the desired output (part of the new ‘columnsummary‘ sample).

Screen Shot 2014-05-05 at 16.30.34

Since we’re now trying to render time dependent data (i.e. it depends on the timeline visualization), we have to get access to the scheduler view which has APIs to get the position based on a date. First we create a new view preset with an empty bottom row renderer.

We also need some data to show in the header. In the sample data, I added some events with a special ‘frozen’ ResourceId set. Here’s the data set loaded:

In our scheduler, I defined a simple XTemplate rendering a simple DIV for each bar.

Then I grab the bottom header row of my custom preset and set a new renderer method which renders these special ‘frozen’ header events.

Now all we have to do is to write the rendering part, by implementing our frozenHeaderRenderer method. We inject all these events in the first header cell, since the getXFromDate method returns values based on the left-most edge of the view.

Keeping the header up to date

The last piece of this puzzle is to make sure the header view is up to date. We do this by simply observing the event store for any changes. When events are added to the eventStore, we simply call ‘refresh’ on the TimeAxisColumn instance.

That’s all it takes. One custom preset, a template and data to apply to the template. I hope you find these tricks useful as you customize your own Scheduler and Gantt components.

Leave a Comment