问题描述
- extjs 点击树tabpanel不出来
- 分成两个写的
Ext.define('MyApp.view.MyPanel' {
extend: 'Ext.panel.Panel'
alias: 'widget.mypanel'requires: [ 'MyApp.view.MyPanelViewModel' 'MyApp.view.MyPanelViewController' 'Ext.tree.Panel' 'Ext.tree.View' 'Ext.tab.Panel']controller: 'mypanel'viewModel: { type: 'mypanel'}height: 634id: 'mainpanel'width: 1001layout: 'border'title: 'My Panel'items: [ { xtype: 'treepanel' region: 'west' split: true width: 150 collapsible: true title: '菜单栏' store: 'MyTreeStore' rootVisible: false listeners: { itemclick: 'itemclick' } } { xtype: 'tabpanel' region: 'center' html: '不将就' itemId: 'tab-3' title: '欢迎' titleCollapse: false listeners: { tabchange: 'tabchange' } }]
});
还有事件:
Ext.define('MyApp.view.MyPanelViewController' {
extend: 'Ext.app.ViewController'
alias: 'controller.mypanel'itemclick: function(dataview record item index e eOpts) { //console.log(this.getRootNode().childNodes[index].data); var json = record.data; Ext.getCmp(mainpanel).down('tabpanel'); var tab = tabs.child('#tab-'+json.id); // 是否添加 if(!tab){ tab = Ext.create('Ext.tab.Tab'{itemId:'tab-'+json.idtitle:json.texthtml:'第'+json.id+'显示'}); //tab = {itemId:'tab-'+json.idtitle:json.texthtml:'fff'}; tabs.add(tab); } // 激活 tabs.setActiveTab(tab);}tabchange: function(tabPanel newCard oldCard eOpts) { // 关联树操作 Ext.getCmp(manelpanel).down('treepanel'); // 非空 if(newCard.itemId){ var sp = newCard.itemId.split('-'); var xpath = ''; // 组成 path for(var i = 1 ; i < sp.length-1 ; i++){ xpath += sp[i]+'/'; } // 最后值 var last = sp.join('-').replace('tab-'''); // 选择 tree tree.selectPath('/root/'+xpath+last); }}
});
时间: 2024-11-05 12:07:04