-
Notifications
You must be signed in to change notification settings - Fork 0
/
a-styles.txt
51 lines (45 loc) · 1.36 KB
/
a-styles.txt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Component } from '@angular/core';
import { GridApi, GridReadyEvent, IGetRowsParams } from 'ag-grid-community';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
columnDefs = [
{ field: 'id', sortable: true, filter: true },
{ field: 'name', sortable: true, filter: true },
{ field: 'age', sortable: true, filter: true },
{ field: 'email', sortable: true, filter: true },
];
defaultColDef = {
flex: 1,
minWidth: 100,
resizable: true,
};
rowData: any[] = [];
private gridApi!: GridApi;
constructor(private http: HttpClient) {}
onGridReady(params: GridReadyEvent): void {
this.gridApi = params.api;
// Set up the datasource for infinite scrolling
const dataSource = {
getRows: (params: IGetRowsParams) => {
const startRow = params.startRow;
const endRow = params.endRow;
this.http
.get<any[]>('/api/data', {
params: {
start: startRow.toString(),
end: endRow.toString(),
},
})
.subscribe((data) => {
params.successCallback(data, 1000000); // Assume server returns total rows
});
},
};
params.api.setDatasource(dataSource);
}
}