2013-10-17 3 views
0

창을 고유 한 것으로 정의하는 방법이 있습니까?
정확히 무슨 뜻입니까? 창이 이미 열려있을 때 다시 열지 않고 포커스를 얻길 원합니다. 지금 내 메뉴 클릭 이벤트에 대한extjs - 창을 고유 한 것으로 정의하는 방법?

는 않습니다 :

onMenuItemClick: function(){ 
    Ext.create('Mb.view.UniqueWindow').show() 
}, 

답변

2

다음, 그것에게 고유 ID를 부여 이미를 작성하기 전에 존재하는지 확인을, 그렇지 않으면 다만,

function onMenuItemClick() { 
var wnd = Ext.getCmp('myUniqueWindow'); 

if (!wnd) { 
    wnd = Ext.create('Ext.window.Window', { 
     id: 'myUniqueWindow', 
     title: 'Unique Window', 
     height: 200, 
     width: 400, 
     layout: 'fit', 
     closeAction: 'hide', // This is really important otherwise closing it will destroy the window! 
     items: { // Let's put an empty grid in just to illustrate fit layout 
      xtype: 'grid', 
      border: false, 
      columns: [{ 
       header: 'Hello World' 
      }], // One header just for show. There's no data, 
      store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store 
     } 
    }); 
} else { 
    wnd.getEl().highlight() 
} 

wnd.show(); 

같은}

0을 보여

당신이 볼 수 있습니다 working sample here

+0

하이라이트 효과는 정말 멋지다. 나는 아직 이것에 대해 몰랐다. –

+0

도움이 되니 기쁘다, ExtJS rocks :) – overlordhammer

1

저장에 대한 참조 :

if (!MyApp.someWin) { 
    MyApp.someWin = new Ext.window.Window(); 
} 
MyApp.someWin.show(); 
관련 문제