@siemens/ngx-datatable
Version:
ngx-datatable is an Angular table grid component for presenting large and complex data.
41 lines (40 loc) • 946 B
TypeScript
import { TableColumnProp } from '../types/table-column.type';
export type OptionalValueGetter = (row: any) => any | undefined;
export declare function optionalGetterForProp(prop: TableColumnProp): OptionalValueGetter;
/**
* This functions rearrange items by their parents
* Also sets the level value to each of the items
*
* Note: Expecting each item has a property called parentId
* Note: This algorithm will fail if a list has two or more items with same ID
* NOTE: This algorithm will fail if there is a deadlock of relationship
*
* For example,
*
* Input
*
* id -> parent
* 1 -> 0
* 2 -> 0
* 3 -> 1
* 4 -> 1
* 5 -> 2
* 7 -> 8
* 6 -> 3
*
*
* Output
* id -> level
* 1 -> 0
* --3 -> 1
* ----6 -> 2
* --4 -> 1
* 2 -> 0
* --5 -> 1
* 7 -> 8
*
*
* @param rows
*
*/
export declare function groupRowsByParents(rows: any[], from?: OptionalValueGetter, to?: OptionalValueGetter): any[];