Filter to not display parent node with no task

Hi,

Please take a look at this snippet

Is there anyway to not display the parent node, if there is no children node?

This is the sample data.

Searching for feedback will result as such.

image

Is there a way to detect and not display Development and Feature develop node if there is no child task after the search.

As I need to always display the parent node if there is a result under the parent node, my approach currently is to always display if it’s a parent which is better than only display the actual task that being searched on.

This is not the desired behavior where the parent node is not shown

image

if (gantt.getChildren(id).length > 0) return true;

Which is really a hack/workaround but I can’t think of a better way at the moment.

Thanks.

Hello Joseph,
I have a little different implementation to show filtered tasks. You can recursively check all children of each task.
Here is the snippet:
https://snippet.dhtmlx.com/9271e3bad

Hi @ramil,

That looks good, thanks! But don’t mind if I ask, why are you doing

match += 1?

Is there a difference if I use match = true instead?

Thanks.

Hello Joseph,
Yes, you can use match = true. The match += 1 selector was used in a different example where it was necessary to select several filters. Here are similar examples where you can check several parameters:
https://snippet.dhtmlx.com/e79b73263
https://snippet.dhtmlx.com/991eba08d

Alright, thanks for the tips.