PDA

View Full Version : Ext.window header contextmenu



doktor
21 Sep 2012, 1:45 AM
Hello!

I recently started learning ExtJS and have question

Can I do context menu in window (Ext.window) header?

redraid
21 Sep 2012, 4:14 AM
You can listen contextmenu event of window header el:


Ext.create('Ext.window.Window', {
title: 'Hello',
height: 200,
width: 400,
layout: 'fit',
items: { // Let's put an empty grid in just to illustrate fit layout
xtype: 'grid',
border: false,
columns: [{header: 'World'}], // One header just for show. There's no data,
store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store
},
listeners: {
boxready: function (win) {
var header = win.down('header');

header.getEl().on('contextmenu', function (e) {
Ext.create('Ext.menu.Menu', {
width: 100,
height: 100,
margin: '0 0 10 0',
items: [{
text: 'regular item 1'
},{
text: 'regular item 2'
},{
text: 'regular item 3'
}]
}).showAt(e.getXY());

e.preventDefault();
return false;
});
}
}
}).show();

doktor
21 Sep 2012, 4:42 AM
Thanks, work!

ps: спасибо, земляк! ;)