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) {
dp.tasks.find(args.data.id).row.collapse();
args.data.box = { bubbleHtml: args.data.box, cssClass: args.data.CssClass };
args.data.row = { bubbleHtml: args.data.row };
args.data.cssClass = args.data.CssClass;
};
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:
console.log(dp.tasks.find(args.data.id).row.expanded());
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.