Get task after filter has been applied


Is there a way to grab task list after filter has been applied?

So using onBeforeTaskDisplay allows me to perform some filtering and such before it is displayed.
But I’ll like to know what’s task list at the end of the filter.

So I can get like

gantt.getAllTaskAfterFilter() which returns me the list of the tasks.

// Update:

Alternatively, maybe have an event that is like gantt.getAllTaskAfterRefreshData(), may work for me as well, but need to test it out.


Hello @Joseph,

To get rendered tasks after the filter has been applied, you should use eachTask() method to iterate over tasks and check the value of the task object property to which filtering is applied.

Please open the console and click on the button Get All Displayed Evs in this snippet to see how it works

Find the function getAllDisplayedEvs() in the code that pushes displayed tasks to the filteredTasks array. You need similar solution to implement such functionality in your application.

Hi @Polina,

Unless I understand wrongly, this solution only work after the fact that filter has already been applied, and manually triggered.

What I need is a event that get triggered after filtered is applied. Like I mentioned, like afterTaskDisplay or similar.

Any solution for that?


this solution only work after the fact that filter has already been applied, and manually triggered.

Yes, but an event that you want also will fire after the filter has already been applied.

There are 2 ways to get an array with displayed tasks if you want it to trigger automatically.

  1. Call the function getAllDisplayedEvs() in the filter_input.onchange event:

  2. Put the code from the function to the onDataRender handler:

Hope that will help you to solve your issue.

Hi @Polina,

It looks good to me at the moment but I’ll have to try it out to know.

Just to understand correctly, calling gantt.refreshData() will trigger both onBeforeTaskDisplay and onDataRender sequentially or is that gantt.refreshData() triggers onBeforeTaskDisplay which then triggers onDataRender?

Also, it is basically running the logic for filter twice, one for onBeforeTaskDisplay, and another one looping through each task to push to the array. Would it be expensive to do so if there is quite a number of tasks, and filter can be easily changed and applied every now and then.


Hi @Joseph,

refreshData calls onDataRender
onBeforeTaskDisplay fires for each rendered event (several times according to numbers of events in data) before onDataRender (this event fire only once in the end).

This is unlikely to affect performance. I can’t say the number of tasks when you may encounter this problem. But it should be high enough.

Hi @Polina,

Just to clarify, if I were to use gantt.render() instead of gantt.refreshData(), the end result would be the same right?

render() calls refreshData which then calls onDataRender.

Using back the same example given above,, instead of calling refreshData, I changed to render.

Noted. Thanks.

Hi @Joseph,

Yes, but render() refreshes the whole Gantt chart. refreshData() refreshes only data.

That is, with a large amount of data, the first method will need more time to refresh Gantt with tasks. The second one is enough for filtering.

Hi @Polina,

Thanks for the clarification.

I would love to use refreshData but there seem to have some rendering issue when using refreshData, hence, I might be force to use render at the moment until a suitable resolution is found.

That’s another issue that I’ve filed, and currently in talk with @ramil.

I will test out your suggestion, and feedback here if there is anything.