Filter on resource select


#1

Hi,

I want to filter data when I click on a resource or task in the resource panel.

Is that possible?


#2

Hello Stefan,
To filter tasks, you need to use the onBeforeTaskDisplay event handler:
https://docs.dhtmlx.com/gantt/api__gantt_onbeforetaskdisplay_event.html

Here are examples of how it can be implemented:
http://snippet.dhtmlx.com/c3c54d10e
http://snippet.dhtmlx.com/c9bfba6fb

If you want to filter resources, you need to use the onFilterItem event handler:
https://docs.dhtmlx.com/gantt/api__gantt_datastore_other.html
Here is an example:
http://snippet.dhtmlx.com/5/bf55798b3


#3

Hi Ramil,

thanks for the quick response! Filtering works… but how can I trigger it by clicking on a row-header in the resource panel like in the screenshot?


#4

Hello Stefan,
You need to use the onEmptyClick event handler that fires when you click on empty space and on the resource cell:
https://docs.dhtmlx.com/gantt/api__gantt_onemptyclick_event.html
There, you need to call the filter function after a timeout. Otherwise, the selected resource will be updated after Gantt repainted the data, and you will need to call the render function more times.
Here is the snippet:
http://snippet.dhtmlx.com/5/28c94bb9e