Browse Source

菜单自动展开选中

zhuth 6 năm trước cách đây
mục cha
commit
40284c1365
1 tập tin đã thay đổi với 17 bổ sung1 xóa
  1. 17 1
      app/controller/Global.js

+ 17 - 1
app/controller/Global.js

@@ -55,11 +55,27 @@ Ext.define('uas.controller.Global', {
     handleRoute: function(target) {
         let me = this,
             contentPanel = me.getContentPanel(),
+            navigationTree = me.getNavigationTree(),
             store = Ext.StoreMgr.get('Navigation'),
             node = store.findNode('target', target),
             title = node.get('text');
         
-        this.getViewport().getViewModel().set('selectedNode', node);        
+        this.getViewport().getViewModel().set('selectedNode', [node]);
+
+        if (node.isRoot()) {
+            navigationTree.ensureVisible(0, {
+                focus: true
+            });
+        } else {
+            if (node.parentNode && !node.parentNode.isExpanded()) {
+                node.parentNode.expand();
+            }
+            navigationTree.ensureVisible(node, {
+                focus: true,
+                select: true
+            });
+        }
+
         Ext.suspendLayouts();
 
         contentPanel.removeAll(true);