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

How to collapse tasks based on field from database

Asked by Anonymous
24 days ago.

Hi, my gantt information comes from a database and i added a field called collapsed with a boolean value. I want to preeminently collapse rows with a true value in that field.

My problem is when I try to do this in onBeofreTaskRendered like this:

 dp.onBeforeTaskRender = function (args) {
       = { bubbleHtml:, cssClass: };
       = { bubbleHtml: };

I get this error:

Uncaught TypeError: Cannot read properties of null (reading 'toggle')
    at o.expanded (daypilot-all.min.js:14:12102)
    at o.collapse (daypilot-all.min.js:14:12223)
    at dp.onBeforeTaskRender (<anonymous>:149:49)
    at s.Jh (daypilot-all.min.js:72:913)
    at s.Ih (daypilot-all.min.js:72:2784)
    at s.xh (daypilot-all.min.js:72:326)
    at daypilot-all.min.js:68:6291

Even though when I try to check whether a given task’s row is expanded buy running:


I do get a value. From what I gather, the code that toggles and/or collapses tasks is creating an error but when I try to call it elsewhere in the code (outside the before render event), it doesn’t work either.

Answer posted by Dan Letecky [DayPilot]
24 days ago.

In onBeforeTaskRender, it is only possible to access the raw data object ( The DayPilot.Task object is not available yet.

To collapse the rows, you can set the property there:

dp.onBeforeTaskRender = function (args) {
  // ... = { bubbleHtml:, collapsed: true };
  // ...
New Reply
This reply is
or drop files here
Your name (optional):