I have added a tab panel in Extjs. When i click on second tab i would like to see a component in header area of tab panel,
at red mark, below in the image.
For a tabpanel component follows another suggestion:
Ext.application({
name : 'TabPanelHeaderButton',
launch : function() {
Ext.create('Ext.tab.Panel', {
width: 400,
height: 400,
renderTo: document.body,
items: [{
title: 'Foo'
},{
title: 'Foo 1'
}],
tabBar: {
items: [{
xtype: 'tbfill'
},{
xtype: 'button',
text: 'Button',
padding: '3px',
margin: '2px 5px 2px 2px',
handler: function(){
alert ('Button click')
}
}]
}
});
}
});
I am not sure whether you can insert button inside tab panel or not.
I have an alternative. Create a floating panel with required button inside it and show this floating panel at required position .
showButtonNextToLastTab : function(){
var me = this;
var lastTab = me.getLastTabInTabPanel();
var tabWidth = lastTab.getWidth();
var tabHeight = lastTab.getHeight();
var btnContainer = Ext.getCmp('btnContainer');
if(btnContainer == null) {
btnContainer = Ext.create('Ext.panel.Panel',{
id: 'btnContainer',
cls: 'btnContainerCls',
floating: true,
shadow : false,
height : 50,
items : [
{
xtype : 'button',
id : 'myRequiredButton',
text:'Button',
cls:'requiredBtnCls',
minWidth : tabWidth,
height : tabHeight
}
]
});
}
btnContainer.showBy(lastTab,'tl-tr',[-2,0]);
},
getLastTabInTabPanel : function(){
var me = this;
var tabPanel = Ext.getCmp('myTabPanel');
if(tabPanel){
var tabBar = tabPanel.getTabBar();
var noOfTabs = tabBar.items.items.length;
return tabBar.items.get(noOfTabs-1);
}
return null;
}
destroyButtonContainerPanel : function(){
var btnContainer = Ext.getCmp('btnContainer');
if(btnContainer != null)
btnContainer.destroy();
}
Call showButtonNextToLastTab method when you want to show this button to show up and call destroyButtonContainerPanel method when you want to hide this button.
Note : 'myTabPanel' is id of tabPanel in which you want to insert this button.
See if this helps..
Related
I create a class of Button and I want that button will appear on number of selection in checkbox. Right now button is appearing only one even though I selected multiple checkbox.
So far I done
I creating button class.
Added into an array
Placing this array in items of panel.
Button class
Record = Ext.extend(Ext.Container,{
initComponent: function(){
var p=this;
p.bodyPadding = 5;
p.margin = '5 5 0 3';
p.layout = 'anchor';
p.items = [{
xtype: 'button',
text : 'Hello
}];
Record.superclass.initComponent.apply(this, arguments); }});
Adding into array in function :
getRecords: function () {
var RecItems[];
recLength = Ext.getCmpBy('Rec').length
var clsName;
clsName = new Record (),
for(var i=0;i<recLength; i++){
var item = Ext.create(clsName,{
});
RecItems.push(item);
}
return RecItems;
}
Calling this in panel
{xtype:'panel',
title : "Records",
bodyStyle: 'background: #dfe8f6;border:#dfe8f6;',
autoScroll: true,
region: 'center',
layout:{
type: 'anchor',
pack: 'start',
align: 'stretch'
},
items: p.getRecords()
}
I am reading data from store and populating main girdView. When any of the row is clicked, a windows appear and I want to fill the fieldset in that window with the same record which is clicked.
Can anyone tell me how to do it?
My popup window is like:
{
extend: 'Ext.window.Window',
height: 500,
width: 1500,
minWidth :1500,
maxWidth :1500,
layout: 'fit',
controller: 'PopUpWindowController',
initComponent: function () {
var me = this;
//console.log(me.myExtraParams);
var Store = Ext.getStore('mainStore');
Ext.applyIf(me, {
/* items: [{
xtype: 'form',
bodyPadding: 10,
region: 'center'
}]*/
});
me.callParent(arguments);
},
items: [
{
xtype: 'panel',
title : 'Projektierung',
bodyStyle : 'padding:5px',
width : 1880,
autoHeight : true,
items:
[
{
xtype : 'kopfdatenView', // Have to populate this view
}
]
}]}
and in Main view I am calling it as:
{
region: 'center',
xtype: 'gridpanel',
listeners : {
itemdblclick: function(dv, record, item, index, e) {
var extra = record.data;
win = Ext.create('App.view.PopUpWindow');
console.log(win.myExtraParams);
win.on('show', function(win) {
win.setTitle(record.get('ID'));
});
win.show();
}
},
columns: [
****
],
store: 'mainStore',
height: 100,
width: 400,
}
I want to populate fieldset in kopfdatenView. Kindly help
You directly pass your record to your window on creation :
win = Ext.create('App.view.PopUpWindow', {
myRecord: record
});
And then inside the window's initComponent function (before the callParent) :
this.title = this.myRecord.get('ID');
You can do something like this:
win = Ext.create('App.view.PopUpWindow', {
params: record
});
Then, in your PopUpWindowController you can retrieve 'params' in the render event (for example).
I have an accordion layout in a window. I don't want the second panel to be expanded.
I've tried with
var intermodPanel = {
xtype : 'panel',
title : 'unexpandable panel',
listeners : {
beforeactivate : function(){
return false;
}
}
}
But it doesn't work. I'm working on Extjs 4.2.
Also, my "plus" and "minus" icons at the right of the header are not displayed, is there something I've missed?
var winPort = Ext.create('widget.window', {
id: 'win' + pointcode,
title: 'a Window' ,
autoScroll: true,
header: {
titlePosition: 2,
titleAlign: 'center'
},
closable: true,
closeAction: 'hide',
width: 822,
height: 533,
layout: 'accordion',
layoutConfig : {
animate : true
},
items : [expandablePanel, unexpandablePanel, expandablePanel]
}).show();
Thank you
Please note that beforeactivate is only valid for Card layout, not for accordion layout: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.AbstractComponent-event-beforeactivate
So, how to make an accordion layout that prevents a card from being opened?
Easy as cake: Just use the correct event.
listeners : {
beforeexpand : function(){
return false;
}
}
I am creating a toolbar in my code below. What I'm wondering is how to place these inside a panel?
var toptoolbar = Ext.create('Ext.toolbar.Toolbar', {
id: 'ttool',
width: '100%',
items: [
{ text : 'MetaCenter',
menu : {
items: [
{ text : 'Wiki' },
{ text : 'JIRA' },
{ text : 'SVN' },
{ text : 'Sharepoint',
menu : {
items: [
{text : 'text 1'},
{text : 'text 2'}
]
}
}]
}
}
]
});
What I want to do is something like:
Ext.create.('Ext.panel.Panel', {
id: 'panel',
tbar: { //code to create the toptoolbar }
....
EDIT:
What I want to have is a very extensive drop down menu with sub menus on a toolbar, I'm trying to avoid putting all of that code to create that toolbar inside of my application. Instead I want to be able to call it from a variable (or better yet, a class?). Kind of like abstraction/encapsulation.
Is this a standard way of component instantiation or are there more-efficient methods?
Cheers!
Check out the ExtJS docs for dockedItems, they give exactly this scenario as an example: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.panel.Panel-cfg-dockedItems
You can define the toolbar in the initComponent method of the panel.
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.panel.Panel',
height: 250,
width: 400,
title: 'My Panel',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
dockedItems: [
{
xtype: 'toolbar',
dock: 'top'
}
]
});
me.callParent(arguments);
}
});
I'm new in extjs.
Currently a panel have been created and set to north region.
Ext.create('Ext.panel.Panel', {
layout: {
type: 'border'
},
bodyStyle: 'background: yellow;',
height : 700,
width : '100%',
renderTo: Ext.get("example"),
items : [{
title: 'navigationBar',
header: false,
region: 'north',
xtype: 'panel',
//margins: '5,5,5,5',
items: [
MenuBar
]
}
And I also create a toolbar in my child class, which ready to call from my parent class and place to the north region panel.
Ext.define('adminInterface', {
extend: 'Ext.toolbar.Toolbar',
items: [{
xtype: 'tbbutton',
text: 'Button',
},{
xtype: 'tbbutton',
text: 'Button1',
menu: [{
text: 'Good',
},{
text: 'Better',
},{
text: 'Best',
}]}]
});
Once I execute the code, the toolbar variable from child class was call, but it not show out the interface.
Thanks for anyone share their information.
Hi refer my sample example
Ext.create('Ext.panel.Panel', {
title: 'Hello',
width: 200,
html: '<p>World!</p>',
renderTo: Ext.getBody(),
tbar: new Ext.Toolbar({
//your Toolbar config options
})
});
Still we can able to see more sample from existing post as shown below
How do i add a toolbar to my layout in extjs?
Extjs 4 add toolbar to panel dockeditems run-time
var myBtnHandler = function(btn) {
Ext.MessageBox.alert('You Clicked', btn.text);
},
fileBtn = Ext.create('Ext.button.Button', {
text : 'File',
handler : myBtnHandler
}),
editBtn = Ext.create('Ext.button.Button', {
text : 'Edit',
handler : myBtnHandler
}),
tbFill = new Ext.toolbar.Fill();
var myTopToolbar = Ext.create('Ext.toolbar.Toolbar', {
items : [
fileBtn,
tbFill,
editBtn
]
});
var myBottomToolbar = [
{
text : 'Save',
handler : myBtnHandler
},
'-',
{
text : 'Cancel',
handler : myBtnHandler
},
'->',
'<b>Items open: 1</b>'
];
var myPanel = Ext.create('Ext.panel.Panel', {
width : 200,
height : 150,
title : 'Ext Panels rock!',
collapsible : true,
renderTo : Ext.getBody(),
tbar : myTopToolbar,
bbar : myBottomToolbar,
html : 'My first Toolbar Panel!'
});