extjs4.0 desktop 桌面菜单动态生成
ShortcutModel.js中多添加几个字段,以自己够使用为准:
Ext.define('Ext.ux.desktop.ShortcutModel', { extend: 'Ext.data.Model', fields: [ { name: 'name' }, { name: 'iconCls' }, { name: 'module' }, { name: 'id' }, { name: 'title' }, { name: 'url' } ] });
Desktop.js中的onShortcutItemClick桌面图标点击事件
//桌面图标点击事件 onShortcutItemClick: function (dataView, record) { if (record.data.module == '') { var me = this, win; win = me.createMyWindow(record.data); if (win) { me.restoreWindow(win); } } else { //原始事件 var me = this, module = me.app.getModule(record.data.module), win = module && module.createWindow(); if (win) { me.restoreWindow(win); } } }, //添加此函数用于生成window createMyWindow: function (win_data) { var desktop = this.app.getDesktop(); var win = desktop.getWindow(win_data.id); if (!win) { win = desktop.createWindow({ id: win_data.id, title: win_data.title, 640, height: 480, html: '<iframe style="position:relative;background-color:transparent;" allowtransparency="true" width="100%" height="100%" frameborder="0" src="' + win_data.url + '"></iframe>', iconCls: 'bogus', animCollapse: false, constrainHeader: true }); } win.show(); return win; },