Skip to content

Commit

Permalink
fix: adding optional tree level property should be used when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Apr 30, 2021
1 parent e684d1a commit a3598c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class Example5 {
enableTreeData: true, // you must enable this flag for the filtering & sorting to work as expected
treeDataOptions: {
columnId: 'title',
// levelPropName: 'treeLevel',
parentPropName: 'parentId',

// you can optionally sort by a different column and/or sort direction
Expand Down
8 changes: 4 additions & 4 deletions packages/common/src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export function castObservableToPromise<T>(rxjs: RxJsFacade, input: Promise<T> |
* @param options you can provide the following options:: "parentPropName" (defaults to "parent"), "childrenPropName" (defaults to "children") and "identifierPropName" (defaults to "id")
* @return roots - hierarchical data view array
*/
export function convertParentChildArrayToHierarchicalView<T = any>(flatArray: T[], options?: { parentPropName?: string; childrenPropName?: string; identifierPropName?: string; }): T[] {
export function convertParentChildArrayToHierarchicalView<T = any>(flatArray: T[], options?: { parentPropName?: string; childrenPropName?: string; identifierPropName?: string; levelPropName?: string; }): T[] {
const childrenPropName = options?.childrenPropName ?? 'children';
const parentPropName = options?.parentPropName ?? '__parentId';
const identifierPropName = options?.identifierPropName ?? 'id';
const hasChildrenFlagPropName = '__hasChildren';
const treeLevelPropName = '__treeLevel';
const treeLevelPropName = options?.levelPropName ?? '__treeLevel';
const inputArray: T[] = deepCopy(flatArray || []);

const roots: T[] = []; // things without parent
Expand Down Expand Up @@ -137,11 +137,11 @@ export function convertHierarchicalViewToParentChildArray<T = any>(hierarchicalA
* @param treeLevel - tree level number
* @param parentId - parent ID
*/
export function convertHierarchicalViewToParentChildArrayByReference<T = any>(hierarchicalArray: T[], outputArrayRef: T[], options?: { childrenPropName?: string; parentPropName?: string; hasChildrenFlagPropName?: string; treeLevelPropName?: string; identifierPropName?: string; }, treeLevel = 0, parentId?: string) {
export function convertHierarchicalViewToParentChildArrayByReference<T = any>(hierarchicalArray: T[], outputArrayRef: T[], options?: { childrenPropName?: string; parentPropName?: string; hasChildrenFlagPropName?: string; levelPropName?: string; identifierPropName?: string; }, treeLevel = 0, parentId?: string) {
const childrenPropName = options?.childrenPropName ?? 'children';
const identifierPropName = options?.identifierPropName ?? 'id';
const hasChildrenFlagPropName = options?.hasChildrenFlagPropName ?? '__hasChildren';
const treeLevelPropName = options?.treeLevelPropName ?? '__treeLevel';
const treeLevelPropName = options?.levelPropName ?? '__treeLevel';
const parentPropName = options?.parentPropName ?? '__parentId';

if (Array.isArray(hierarchicalArray)) {
Expand Down

0 comments on commit a3598c5

Please sign in to comment.