-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformFunction.ts
More file actions
35 lines (29 loc) · 882 Bytes
/
Copy pathTransformFunction.ts
File metadata and controls
35 lines (29 loc) · 882 Bytes
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
// Transform function
setWarningFlags<T extends { hierarchyRow: { nextLevel: any } }>(data: T[]): (T & { isWarning: boolean })[] {
return data.map(row => ({
...row,
isWarning: !row.hierarchyRow.nextLevel
}));
}
// Usage in datasource
const processedData = this.setWarningFlags(response.data);
// In your datasource getRows
createServerSideDatasource(): IServerSideDatasource {
return {
getRows: (params: IServerSideGetRowsParams) => {
this.dataService.getData(params.request).subscribe({
next: (response) => {
const processedData = response.data.map(row => ({
...row,
isWarning: !row.hierarchyRow.nextLevel
}));
params.success({
rowData: processedData,
rowCount: response.totalCount
});
},
error: () => params.fail()
});
}
};
}