From 5ae243b26c401babedde32f1f270713da2a59bd0 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 20 Dec 2017 15:34:17 +0300 Subject: [PATCH] Expand treeview to selected level. --- apps/common/main/lib/component/TreeView.js | 34 +++++++++++++++++++ .../main/app/controller/Navigation.js | 5 +++ .../main/app/view/Navigation.js | 14 ++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/apps/common/main/lib/component/TreeView.js b/apps/common/main/lib/component/TreeView.js index fd89c1f9d..e28c9fae2 100644 --- a/apps/common/main/lib/component/TreeView.js +++ b/apps/common/main/lib/component/TreeView.js @@ -114,6 +114,35 @@ define([ item.set('isExpanded', false); i = this.collapseSubItems(item); } + }, + + expandToLevel: function(expandLevel) { + var me = this; + var _expand_sub_items = function(idx, level) { + var parent = me.at(idx); + parent.set('isExpanded', false); + for (var i=idx+1; ilevel) { + if (item_level<=expandLevel) + parent.set('isExpanded', true); + item.set('isVisible', item_level<=expandLevel); + if (item.get('hasSubItems')) + i = _expand_sub_items(i, item_level ); + } else { + return (i-1); + } + } + }; + + for (var j=0; j