UNPKG

@siemens/ngx-datatable

Version:

ngx-datatable is an Angular table grid component for presenting large and complex data.

42 lines (41 loc) 1.05 kB
import { TableColumnProp } from '../types/table-column.type'; import { Row } from '../types/public.types'; export type OptionalValueGetter = ((row: any) => any) | undefined; export declare function optionalGetterForProp(prop: TableColumnProp | undefined): 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<TRow extends Row>(rows: (TRow | undefined)[], from?: OptionalValueGetter, to?: OptionalValueGetter): (TRow | undefined)[];