Sencha Touch : vbox inside hbox layout issue - extjs

I am putting a vbox layout inside hbox layout. But the vbox isn't working properly. Here is the code:
Code:
var panel = new Ext.Panel({
fullscreen : true,
layout : {
type : 'hbox',
align : 'stretch'
},
items : [{
width : 50,
layout : {
type : 'vbox',
align : 'stretch'
},
items : [{
flex : 1,
html : '1st'
}, {
height : 50,
html : '2nd'
}]
}, {
flex : 1,
html : 'Large'
}]
});
Here, the 2 panels of vbox is coming over one another. If I just create the vbox only, it works perfectly. Here is the code:
Code:
var panel = new Ext.Panel({
fullscreen : true,
layout : {
type : 'vbox',
align : 'stretch'
},
items : [{
flex : 1,
html : '1st'
}, {
height : 50,
html : '2nd'
}]
});
Am I doing anything wrong?
EDIT:
Somehow, I find, if I swap the vbox items this way, then it works:
...
layout : {
type : 'vbox',
align : 'stretch'
},
items : [{
height : 50,
html : '2nd'
}, {
flex : 1,
html : '1st'
}]
....
However, I want the smaller item at the bottom.

In your hbox, the vbox itself is missing a flex or height config...
var panel = new Ext.Panel({
fullscreen: true,
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
width: 50,
flex:1, // this needs to be flexy as well
layout: {
type: 'vbox',
align: 'stretch'
},
items: [{
flex: 1,
html: '1st'
}, {
height: 50,
html: '2nd'
}]
}, {
flex: 1,
html: 'Large'
}]
});

Related

ExtJs FormPanel Buttons not shown

I'm trying to build a FormPanel in my application, made by a field and two buttons.
The problem is that, while textfield is shown, Buttons are not shown on the view!
This is the Login.js view:
Ext.define('appTrial.view.Login',{
extend: 'Ext.form.Panel',
xtype: 'Login',
alias: 'widget.Login',
config : {
id : 'LoginId',
title : 'Welcome',
resizable : false,
collapsible : true,
bodyPadding : '5',
buttonAlign : 'center',
border : false,
trackResetOnLoad : true,
items : [{
docked: 'top',
xtype: 'titlebar',
title: 'Welcome to My New App!!!'
},
{
xtype: 'container',
name: 'mainContainer',
layout: {
type: 'vbox',
align: 'center',
pack: 'center'
},
//width : '100%',
items : [{
layout: {
pack: 'center'
},
html :'Associa attivita',
margin: '80 0 0 0'
},{
xtype: 'fieldset',
items: [{
xtype: 'textfield',
name: 'codAttivita'
}]
}],
buttons :[{
text : 'Associa',
itemId : 'btnAssocia',
formBind : true,
ui: 'confirm'
},{
text : 'Reset',
itemId : 'btnReset',
formBind : true,
ui: 'decline'
}]
}]
}
});
Does anyone have any idea?
Thanks in advance
Containers doesn't have the button config. You must define the button config into the formpanel object.

Sencha Sliding Navigation Menu - facebook style - Adding a Panel with two child panels as a separate xtype

I downloaded the latest version of https://github.com/wnielson/sencha-SlideNavigation and in the view/Main.js , for the Item1/Group 1 item, added toolbar + 2 panels, instead of toolbar + 1 panel, the code works fine:
{
title : 'Item1',
group : 'Group 1',
xtype : 'container',
// Enable the slide button using the
// defaults defined above in
// `slideButtonDefaults`.
slideButton : true,
layout: 'vbox',
items : [
{
xtype : 'toolbar',
title : 'Item 1',
docked : 'top'
},
{
xtype : 'panel',
style: 'background: red',
html: 'New1',
flex: 1,
// Mask this item when the
// container is opened
maskOnOpen : true
},
{
xtype : 'panel',
style: 'background: green',
html: 'New2',
flex: 2,
// Mask this item when the
// container is opened
maskOnOpen : true
}
]
},
The code works fine - it replaces the image you have in your demo with a panel with two vertically placed subpanels in red and green
I am trying to refactor the code into into separate view
Ext.define('Volt.view.FeedView', {
extend: 'Ext.Panel',
requires: [
'Ext.TitleBar',
'Ext.Button',
'Ext.Toolbar',
//'Ext.Panel'
],
xtype: 'feedViewCard',
config: {
iconCls: 'action',
title: 'FeedView',
layout:
{
type: 'vbox'
},
items : [
{
xtype : 'toolbar',
title : 'FeedView',
docked : 'top'
},
{
xtype : 'container',
style: 'background: red',
html: 'New1',
flex: 1
// Mask this item when the
// container is opened
//maskOnOpen : true
},
{
xtype : 'container',
style: 'background: green',
html: 'New2',
flex: 1
// Mask this item when the
// container is opened
//maskOnOpen : true
}
]
}
});
and use the following code in view/Main.js , removing the earlier code- there are no errors, but only the green box shows up
{
xtype: 'feedViewCard',
title : 'Home Page',
group : 'Group 1',
slideButton : true
},
Also, this refactored FeedView.js shows up as two child panels when used in a TabPanel view - so it is definitely working fine. Any advice? Thanks much

How to insert a toolbar to the panel that I have been created? Extjs

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!'
});

ExtJs - Make textarea always fit parent panel

How can I set a textarea to always have the width and height of the parent panel that it is added to?
What I tried:
layout : 'fit',
items : [
{
xtype : 'panel',
title : 'XML definition',
lid : 'paneltextarea',
autoScroll: true,
autoWidth: true,
flex : 1
}
]
Into 'paneltextarea', this textarea will be added:
oTextarea = [{
xtype : 'textareafield',
name : 'message',
// value: strValue,
flex: 1,
border: 0,
style : { border: 0 },
lid: 'ietextarea'
}];
I forgot to set layout : 'fit' in the parent.

Align components in the center in a Panel: EXT JS

I am new to ext JS and I am tryin gto place 3 components in a FormPanel but I don't know ho wto align them in the center.
Here is my code
var durationForm = new Ext.FormPanel({
border : false,
labelAlign : 'top',
frame : true,
bodyStyle : 'padding-left:475px;',
items: [{
items: [{
rowWidth : .5,
layout :'column',
items:[{
columnWidth : .13,
layout : 'form',
items : [getNewLabel('<br/><font size="3">Duration: </font>')]
},{
columnWidth : .20,
layout : 'form',
items : [fromDate()]
},{
columnWidth : .17,
layout : 'form',
items : [toDate()]
}]
}]
}]
});
durationForm.render(Ext.getBody());
This shows output like this
But I want components to be align in the center of the panel. Anyone know how to do it?
I have solved this problem by using 'table' layout:
{
layout : 'fit', // parent panel should have 'fit' layout
items : [ // and only one item
{
xtype : 'panel',
border : false, // optional
layout : {
type : 'table',
columns : 1,
tableAttrs : {
style : {
width : '100%',
height : '100%'
}
},
tdAttrs : {
align : 'center',
valign : 'middle',
},
},
items : [ // a single container for nested components
{
xtype : 'panel',
layout : 'fit',
cellId : 'cell_id', // this one will be placed as id for TD
items : [
{}, {}, {} // nested components
]
}
]
}
]
}
{
//...
layout:'hbox',
layoutConfig: {
padding:'5',
pack:'center',
align:'middle'
},
items:[{
columnWidth : .13,
layout : 'form',
items : [getNewLabel(...)]
},{
columnWidth : .20,
layout : 'form',
items : [fromDate()]
},{
columnWidth : .17,
layout : 'form',
items : [toDate()]
}]
//...
}
See this
Just in case someone comes along looking for the answer like I did and couldn't find it here, use xtype:'splitter' between each item like so -
items:[{
xtype:'something'
},
{
xtype:'splitter'
},
{
xtype:'something-else'
}
}]

Resources