Hi Team,
I have implemented Column Hiding using toolbar. I want to update the columns config when show all/ Hide all button is clicked but i am not able to trigger any events for that button click. Kindly let me know if there are any click events for Hide All and Show All button. Kindly let me know if there are any ways to custom overide the Hide All and Show All Button in Column Hiding Component. Please find my sample stackblitz code.
stackblitz - Infragistics Angular Components - StackBlitz
Regards,
Vijay V
Hello Vijay,
I have been looking into your question and currently the igx-grid-toolbar-hiding component does not offer events for ‘Hide All’ and ‘Show All’ buttons. For now, there are events for the ‘Hide’ button itself in the grid toolbar whether it is opened or closed, as well as for selecting the columns individually with the checkboxes whether to be hidden or visible with the columnToggle event.
This is why click events and other events according to your requirements and custom logic for ‘Hide All’ and ‘Show All’ buttons have been determined to be a feature request. You can submit a feature request in our GitHub repository here.
Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case.
However, at this point your requirements can be achieved entirely with JavaScript. For this purpose, you will handle the ngAfterViewInit lifecycle hook and when the grid is loaded and rendered you can access the hide button with the getElementsByClassName method by passing the igx-button--outlined class to the button.
let hideButton = document.getElementsByClassName('igx-button--outlined');
You can then add a click event listener to the given button with the addEventListener method and execute a given function or custom logic when that button is clicked.
hideButton[0].addEventListener('click', function () { });
What will be done after clicking, that is, after opening the drop-down for hiding or visualizing columns, is to take the two buttons ‘Hide All’ and ‘Show All’ inside the drop-down menu. Again, in the same way, we can access the buttons with the getElementsByClassName method by passing igx-button--flat the button class. The first button will be ‘hide all’ and the second button will be ‘show all’.
let hideShowAllButtons = document.getElementsByClassName('igx-button igx-button--flat'); let hideAll = hideShowAllButtons[0]; let showAll = hideShowAllButtons[1];
After that, a click listener will be added to both buttons so that when they are clicked, you can execute your custom logic according to the given event.
hideAll.addEventListener('click', function () { //custom logic here }); showAll.addEventListener('click', function () { //custom logic here });
The described scenario could be observed here:
In addition, I have prepared small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.
Regarding your other question about overriding buttons you can override the styles and appearance of the buttons such as their texts for the given button with the checkAllText and uncheckAllText properties or style them to your preference by selecting them and setting custom forces. More information about styling Column Hiding UI can be found in this topic in our Angular documentation.
If you require any further assistance on the matter, please let me know.
Georgi Anastasov
Entry Level Software Developer
Infragistics
Hi,
Thanks for your response. The sample shared by you is working fine. In IgxGridToolbarColumnHidingComponent, we have two methods checkAll() and uncheckAll() Kindly let us know how we can trigger these methods and let us know if we are able to achieve the expected above functionality using these two methods.
Regards,Vijay V
Hello,
I have been looking into your question and if you mean that you want to handle these events that you put in the igx-grid-toolbar-hiding component and perform certain methods when they are executed, this cannot be done because such events do not exist for the moment in igx-grid-toolbar-hiding component and cannot handle them.
This is your code with the events you set and their handling, which for now, as I said above, can be considered a feature request.
<igx-grid-toolbar-hiding (checkAll)="checkAll($event)" (uncheckAll)="uncheckAll($event)"></igx-grid-toolbar-hiding>
On the other hand, if you had in mind that you want to execute these methods when the given ‘Hide All’ and ‘Show All’ buttons are clicked in the event listener for click body, then what you can do is at the beginning when handling the ngAfterViewInit lifecycle hook to add a variable that to point to ‘this’ key word. This is because we are using JavaScript callback functions in the ngAfterViewInit hook and ‘this’ will not be usable, so a variable/reference is made to it. Then with this variable you can call and execute the given methods in the event listener body for click callback functions for the given buttons.
var _this = this; hideAll.addEventListener('click', function () { _this.checkAll(); }); showAll.addEventListener('click', function () { _this.uncheckAll(); });
In addition, I have modified my previous sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.
Thank you for your cooperation.