-
Notifications
You must be signed in to change notification settings - Fork 0
/
rowselection.ts
36 lines (33 loc) · 1.03 KB
/
rowselection.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Component } from '@angular/core';
@Component({
selector: 'app-my-grid',
template: `
<ag-grid-angular
style="width: 100%; height: 500px;"
class="ag-theme-alpine"
[rowData]="rowData"
[columnDefs]="columnDefs"
rowSelection="multiple"
[rowMultiSelectWithClick]="true"
(selectionChanged)="onSelectionChanged($event)">
</ag-grid-angular>
`,
})
export class MyGridComponent {
columnDefs = [
{ headerName: 'Select', checkboxSelection: true, width: 50 },
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' },
];
rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 },
];
onSelectionChanged(event: any) {
const selectedNodes = event.api.getSelectedNodes();
const selectedData = selectedNodes.map(node => node.data);
console.log('Selected data:', selectedData);
}
}