0
votes

I have implemented sorting of the the selected items in AG-Grid on a button click other than header click.
Ag grid by default needs a ctrl/shift key to be pressed while selecting multiple columns. I want to override this behavior and use the above button as flag instead of key press.


Is it possible to do this? I do not want Pinned rows.

2
Ag-Grid community no longer seems to be very active - Arun

2 Answers

0
votes

You can use the ag-grid sorting API. It is documented here. Using this you can update the sort model on button click.

0
votes

Did some hack and made it work.

/*onGridReady of ag-grid options*/
onGridReady: () => this.agHeaderClickListener()



    /** This function adds listener to Ag grid header click event for all columns */
    agHeaderClickListener() {
        console.log( this.elRef.nativeElement.querySelectorAll('.ag-header-cell-label'));
        let nodeList =  this.elRef.nativeElement.querySelectorAll('.ag-header-cell-label');
            for (let node of nodeList) {
                /** IE Fix */
               if (node.addEventListener) {
                   node.addEventListener('click', this.selectionChanged.bind(this));
               } else {
                   node.attachEvent('onclick', this.selectionChanged.bind(this));
               }
            }
      }

use the selectionChanged(event: any) to do the logical changes you want