Expand treeview to selected level.
This commit is contained in:
parent
ae11df6ed3
commit
5ae243b26c
|
@ -114,6 +114,35 @@ define([
|
||||||
item.set('isExpanded', false);
|
item.set('isExpanded', false);
|
||||||
i = this.collapseSubItems(item);
|
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; i<me.length; i++) {
|
||||||
|
var item = me.at(i);
|
||||||
|
var item_level = item.get('level');
|
||||||
|
if (item_level>level) {
|
||||||
|
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<this.length; j++) {
|
||||||
|
var item = this.at(j);
|
||||||
|
if (item.get('level')<=expandLevel) {
|
||||||
|
item.set('isVisible', true);
|
||||||
|
j = _expand_sub_items(j, item.get('level'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -206,6 +235,11 @@ define([
|
||||||
collapseAll: function() {
|
collapseAll: function() {
|
||||||
this.store.collapseAll();
|
this.store.collapseAll();
|
||||||
this.scroller.update({minScrollbarLength: 40});
|
this.scroller.update({minScrollbarLength: 40});
|
||||||
|
},
|
||||||
|
|
||||||
|
expandToLevel: function(expandLevel) {
|
||||||
|
this.store.expandToLevel(expandLevel);
|
||||||
|
this.scroller.update({minScrollbarLength: 40});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})());
|
})());
|
||||||
|
|
|
@ -92,6 +92,7 @@ define([
|
||||||
panelNavigation.viewNavigationList.on('item:click', _.bind(this.onSelectItem, this));
|
panelNavigation.viewNavigationList.on('item:click', _.bind(this.onSelectItem, this));
|
||||||
panelNavigation.viewNavigationList.on('item:contextmenu', _.bind(this.onItemContextMenu, this));
|
panelNavigation.viewNavigationList.on('item:contextmenu', _.bind(this.onItemContextMenu, this));
|
||||||
panelNavigation.navigationMenu.on('item:click', _.bind(this.onMenuItemClick, this));
|
panelNavigation.navigationMenu.on('item:click', _.bind(this.onMenuItemClick, this));
|
||||||
|
panelNavigation.navigationMenu.items[11].menu.on('item:click', _.bind(this.onMenuLevelsItemClick, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
updateNavigation: function() {
|
updateNavigation: function() {
|
||||||
|
@ -176,6 +177,10 @@ define([
|
||||||
} else if (item.value == 'collapse') {
|
} else if (item.value == 'collapse') {
|
||||||
this.panelNavigation.viewNavigationList.collapseAll();
|
this.panelNavigation.viewNavigationList.collapseAll();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onMenuLevelsItemClick: function (menu, item) {
|
||||||
|
this.panelNavigation.viewNavigationList.expandToLevel(item.value-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, DE.Controllers.Navigation || {}));
|
}, DE.Controllers.Navigation || {}));
|
||||||
|
|
|
@ -75,7 +75,6 @@ define([
|
||||||
});
|
});
|
||||||
this.viewNavigationList.cmpEl.off('click');
|
this.viewNavigationList.cmpEl.off('click');
|
||||||
this.navigationMenu = new Common.UI.Menu({
|
this.navigationMenu = new Common.UI.Menu({
|
||||||
// menuAlign : 'tr-br',
|
|
||||||
items: [{
|
items: [{
|
||||||
caption : this.txtPromote,
|
caption : this.txtPromote,
|
||||||
value: 'promote'
|
value: 'promote'
|
||||||
|
@ -116,6 +115,16 @@ define([
|
||||||
{
|
{
|
||||||
caption : this.txtCollapse,
|
caption : this.txtCollapse,
|
||||||
value: 'collapse'
|
value: 'collapse'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
caption : this.txtExpandToLevel,
|
||||||
|
menu: new Common.UI.Menu({
|
||||||
|
menuAlign: 'tl-tr',
|
||||||
|
items: [{ caption : '1', value: 1 }, { caption : '2', value: 2 }, { caption : '3', value: 3 },
|
||||||
|
{ caption : '4', value: 4 }, { caption : '5', value: 5 }, { caption : '6', value: 6 },
|
||||||
|
{ caption : '7', value: 7 }, { caption : '8', value: 8 }, { caption : '9', value: 9 }
|
||||||
|
]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
@ -145,7 +154,8 @@ define([
|
||||||
txtNewHeading: 'New subheading',
|
txtNewHeading: 'New subheading',
|
||||||
txtSelect: 'Select content',
|
txtSelect: 'Select content',
|
||||||
txtExpand: 'Expand all',
|
txtExpand: 'Expand all',
|
||||||
txtCollapse: 'Collapse all'
|
txtCollapse: 'Collapse all',
|
||||||
|
txtExpandToLevel: 'Expand to level...'
|
||||||
|
|
||||||
}, DE.Views.Navigation || {}));
|
}, DE.Views.Navigation || {}));
|
||||||
});
|
});
|
Loading…
Reference in a new issue