DHTMLX / gantt

GPL version of Javascript Gantt Chart
https://dhtmlx.com/docs/products/dhtmlxGantt/
GNU General Public License v2.0
1.48k stars 324 forks source link

How to disable single task selection when I use multi-select #98

Open guyutian opened 1 year ago

guyutian commented 1 year ago

hello, How to disable single task selection when I use multi-select attribute, 'onTaskClick' event doesn't work properly

gearcoded commented 1 year ago

@guyutian, the onTaskClick event fires after the onBeforeTaskSelected event, so you cannot use it to cancel the task selection with ordinary clicks. You will need to use a different approach.

You can add the mousedown event handler and check if you clicked on a task bar in the timeline or on the task row in the grid. If you didn't press the Shift or Control key, you can save the task ID in a variable. Then you can return false in the onBeforeTaskSelected event handler if the ID matches the task ID.

Here is the snippet: https://snippet.dhtmlx.com/3umuzpfw