AgGrid "Columns Tool Panel" checkboxes, how to trigger onCheck event?

57 views Asked by At

I am using Aggrid, and I need to trigger a onCheck event in the sidebar (Columns Tool Panel). tldt : Is there a way to get the onCheck event of the sidebar (Columns Tool Panel) ?

I don't find the info here : https://www.ag-grid.com/javascript-data-grid/side-bar/

and neither here Tool Panel Columns

My needs is the following : My columns can be visible or not when aggrid get loaded the first time. Then I can tick some hidden column in the side bar to show it up. But some column can have children column (not aggrid children), so if I tick a parent column (not aggrid parent), child must be also ticked.

Problem is that child can be also parent, so I used onColumnVisible event, and it is cascading. I don't want the cascading effect. So I would need a onCheck event.

I used onColumnVisible event, and it is cascading as a child become visible and trigger again. I don't want the cascading effect

I am expecting to have an onCheckEvent so only this column can trigger my function to tick child.

1

There are 1 answers

0
Chaveex On

I finally managed to avoid cascading. onColumnVisible event has a property named "source" which is equals to "toolPanelUi" when onColumnVisible is triggered from "Columns Tool Panel"

Object { type: "columnVisible", visible: true, columns: (1) […], column: {…}, source: "toolPanelUi", api: {…}, columnApi: {…}, context: undefined }

And has value "gridOptionsChanged" when undirect changed

Object { type: "columnVisible", visible: true, columns: (2) […], column: null, source: "gridOptionsChanged", api: {…}, columnApi: {…}, context: undefined }

So I could filter event source to avoid cascading.