How to get selected records on custom toolbar click?
This article explains how to get selected records on custom toolbar click. You can get the selected records in the 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 a 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

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