Articles in this section
Category / Section

How to get selected records on custom toolbar click?

1 min read

You can get the selected records in grid by using getSelectedRecords or getSelectedRows method. The getSelectedRecords method returns the collection of selected records data as object while the getSelectedRows method returns the collection of selected row elements. You can use either of the methods as per your requirement.

This is demonstrated in the below code snippet and sample on custom toolbar button click in the toolbarClick event.

<script>
    // Toolbar click event function
    function clickHandler(args: ClickEventArgs) {
        if (args.item.id === 'selected_records') {
            // Returns the collection of selected row elements
            console.log(grid.getSelectedRows());
            // Returns the collection of selected records data
            console.log(grid.getSelectedRecords());
        }
    }
</script>

 

Output

Selected records

 

JavaScript (ES5) Sample: https://stackblitz.com/edit/hfdp9b?file=index.js

Vue.js Sample: https://plnkr.co/edit/hJxyQFxbDD8lpmXfAPiT

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please  to leave a comment
Access denied
Access denied