ExtJs - border layout - splitter config - extjs

My panel with border layout looks like this:
var oSplitPanel = Ext.create('Ext.panel.Panel', {
lid : 'splitpanel',
layout: 'border',
border: 0,
style: { border: 0 }
height: 150,
items: [{
split: true,
flex: 1,
region: 'west',
xtype: 'panel',
lid: 'panelwest',
layout: 'fit',
minWidth: 200
}]
});
Then another panel gets added to this west region panel:
oSplitPanel.query('[lid=panelwest]')[0].add(oExplorerPanel);
Then this split panel gets added to my main view:
that.getView().add(oSplitPanel);
Then in another function, I add the center panel:
var oAddPanelRight = {
split: true,
flex: 3,
region: 'center',
xtype: 'panel',
lid: 'panelcenter',
layout: 'fit',
border: 0
};
oSplitPanel.add(oAddPanelRight);
Problem:
Everything works perfect this way, however I want to change (limit) the splitter's own width (this splitter is in between west and center panels to resize their width).
What I tried:
Try to change the width of splitters:
listeners: {
afterrender: function() {
// error following, 'splitters' does not exist
oSplitPanel.layout.splitters.west.setWidth(1);
oSplitPanel.doLayout();
}
}
Adding a negative margin to the center panel:
// Tried this:
margin: '0 0 0 -4'
// And that:
style: {
border: 0,
marginLeft: '-3px'
}

Or use event "add"
listeners: {
add: function (me, item) {
if (item.xtype == 'bordersplitter') item.width = 2;
}
},
Demo here http://ext4all.com/post/extjs-4-border-layout-splitter-width

Your oSplitPanel object/instance does not have the split param set to true and has therefor no splitter applied. The splitter get applied to oAddPanelRight object/instance and the nested panel of the oSplitPanel, maybe also to the panel you add later. Can't tell that.
So you just looked at the wrong class.
Btw. to get a splitter for the class itself you don't need look at oSplitPanel.layout.splitters Just look at the splitter prop of the class.

Related

Unable to view Grid when inside hbox (layout) type container

PieChartContainer = Ext.create('Ext.container.Container', {
layout: {
type: 'hbox',
align: 'left'
},
border: 1,
style: { borderColor: '#000000', borderStyle: 'solid', borderWidth: '1px' }
});
then i put following grid inside:
var DataSummaryTable = Ext.create('Rally.ui.grid.Grid', {
itemId: 'summaryData',
store: Ext.create('Rally.data.custom.Store', {
data: [
{
Name: 'num of user stories',
Val: NumOfStories
},
....
....
PieChartContainer.add(DataSummaryTable);
If i remove the layout{...} part from container then i can see the grid. Otherwise grid is not viewable.
I am trying to put two pie charts and a small grid in an hbox layout. how do i do that?
Thanks.
It might depend on the parent of this container. For example, if the parent of this container has a layout of 'fit', then your container should have a config flex: 1.

Ext JS Image in Viewport

I need some help in inserting an image in 'north' panel of Viewport.
The prob is, upon page load, size of north region is set to default: 20px. As a result, only some portion of image is visible. I want it to be adjusted as per the image height.
But as I click on split panels, it adjusts as per the size of image (seems some rendering problem at load?)
following is the ext js code.. Using Ext Js 5.0
Ext.create('Ext.container.Viewport', {
renderTo: Ext.getBody(),
layout: 'border',
items: [
{
region: 'north',
html: '<img src="..." alt="" />',
border: false,
margin: '0 0 0 0',
},{
region: 'center',
xtype: 'tabpanel', // TabPanel itself has no title
activeTab: 0, // First tab active by default
items: {
title: 'Contents',
html: 'The first tab\'s content. Others may be added dynamically'
}
}
]
});
Thanks in advance!
First problem is that when you use border layout, few items are required:
Any Container using the Border layout must have a child item with region:'center'. The child item in the center region will always be resized to fill the remaining space not used by the other regions in the layout.
Any child items with a region of west or east may be configured with either an initial width, or a Ext.layout.container.Box.flex value, or an initial percentage width string (Which is simply divided by 100 and used as a flex value). The 'center' region has a flex value of 1.
Any child items with a region of north or south may be configured with either an initial height, or a Ext.layout.container.Box.flex value, or an initial percentage height string (Which is simply divided by 100 and used as a flex value). The 'center' region has a flex value of 1.
See the doc for more info.
So I would change your panel to hbox, set the main container with flex: 1 and add some logic to make sure that when you load the images the container's layout is updated to fix it's height.
Code below, hope it helps:
Ext.create('Ext.container.Viewport', {
renderTo: Ext.getBody(),
layout: 'vbox',
items: [
{
border: false,
margin: '0 0 0 0',
items : [{
xtype : 'image',
src : 'http://cdn.sencha.io/img/touch2/Sencha-SDK-Tools-icon.png',
listeners : {
boxready : function (component) {
component.getEl().on('load', function(){
component.ownerCt.updateLayout();
});
}
}
}],
layout: {
type: 'anchor'
}
},{
flex: 1,
xtype: 'tabpanel', // TabPanel itself has no title
activeTab: 0, // First tab active by default
items: {
title: 'Contents',
html: 'The first tab\'s content. Others may be added dynamically'
}
}
]
});

adding panel within panel dynamically with autoadjust

I want to add panels within a panel dynamically, since i dont know upfront the numbers of panels which i need to add.
This works fine if i do
panel.insert(<panel to be added>);
The parent panel is configured with the hbox layout.
But if the overall width of added panels goes beyond the parent panel width then there is a overflow and a horizontal scrollbar appears.
Rather what i am looking is it should add the panels to the next line automatically if it reaches the parent panels width.
Any solution to the above problem, might be i need to use some other layout here but not sure on that.
Thanks
I have one idea but you should try in your code then let me know the result. Basically, set layout type to auto.
var resultsPanel = Ext.create('Ext.panel.Panel', {
title: 'Results',
width: 600,
height: 400,
id: 'panel_one',
renderTo: Ext.getBody(),
layout: {
type: 'auto', // Arrange child items vertically
align: 'stretch', // Each takes up full width
padding: 5
}
});
var opanel = Ext.getCmp('panel_one');
console.log(opanel);
opanel.add([
{
xtype: 'panel',
title: 'Inner Panel',
width: Ext.getCmp('panel_one').getWidth(),
height: 100
}
]);
opanel.add([
{
xtype: 'panel',
title: 'Inner Panel',
width: Ext.getCmp('panel_one').getWidth()
height: 100
}
]);
Parent panel layout should be Table with number of columns specified.
See the following code for parent panel
{
xtype: 'panel',
itemId: 'productListPanel',
height: 500,
width: 600,
layout: {
type: 'table',
columns: 3
},
autoScroll: true
}
now i can add any number of child panels to it, see the following code.
for (var i = 0; i < 10; i++) {
var panel = Ext.create('Ext.panel.Panel', {
width: 190,
height: 150,
padding: 10,
cls: 'myPanel',
title: "Child Panle"+i
});
parentPanel.insert(panel);
}
This solved my problem, hope it helps somebody.
Thanks

ExtJS: 'next to centre'

I'd like to achieve this in ExtJS 4.2:
e.g. a centred button, with something (a progress indicator) to its right that doesn't result in the button moving.
All my layouts are currently relative, largely using HBox & VBox, and I'd like to keep it this way rather than using anything absolute to solve this.
There are probably lots of ways to do this, but many of them will be horrible. I guess the 'floating' attribute might play a part, but I can't quite work that out.
Any suggestions?
Use the HBox layout's pack config to display the items in the center, and apply a margin equal to the progess bar's width to the left side of the button:
{
layout: {
type: 'hbox',
pack: 'center'
},
items: [{
xtype: 'button',
text: 'Push me',
width: 100,
margin: '0 0 0 100' // margin-left equal to the width of the progress bar
},{
xtype: 'progressbar',
width: 100
}]
}
Also check out this fiddle.
Here is my attempt, let me know if it's a problem.
Ext.onReady(function() {
var ct = new Ext.panel.Panel({
width: '100%',
renderTo: Ext.getBody(),
margin: 10,
border: true,
id: 'ppanel',
layout: {
type: 'hbox',
},
items: [{
xtype: 'button',
text: 'Push me',
width: 100,
id: 'bbutton'
},{
xtype: 'progressbar',
width: 100,
id: 'pbar'
}],
listeners: {
afterrender: function() {
pwidth = Ext.getCmp('ppanel').getWidth();
bwidth = Ext.getCmp('bbutton').getWidth();
button = Ext.getCmp('bbutton');
progrs = Ext.getCmp('pbar');
bmargin = (pwidth/2 - bwidth/2);
button.setMargin("0 0 0 "+bmargin);
progrs.setMargin("0 0 0 10");
}
}
});
});

positioning of a container in extjs

In my project, I am trying to position a container as absolute. but if I do so, it is also effecting the neighbour items. I mean, after positioning the container, if I give some width and height to that particular container, it is effecting all the toolbar. (which I don't want to happen). This effect is happening even if I use layout: 'absolute or css position:absolute.
Here is my related code:
xtype: 'panel',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 40,
items: [
{
//only this should be absolute positioned
xtype: 'container',
cls: 'logo', //tried with applying css styles !important
//even tried with layout: 'absolute'
},'-',
//the below elements should not move their position
//even if the above one has been applied positioning.
{
xtype: 'container'
},'->',
{
xtype: 'container'
}]
}],
Here my goal is to bring the container out of the toolbar because it should have greater height than the toolbar keeping other containers constant.
If the profile pic container has to be higher than the toolbar, it can't be a child of the toolbar container.
You could create a container with absolute layout below the toolbar, in that container you will have the profile pic and you can use a negative Y variable in order to move up the image, so it looks like is in the toolbar.
Just like this
var toolbar = Ext.create('Ext.toolbar.Toolbar', {
items: [
{},
{ xtype: 'tbspacer', width: 50 }, // Moving the button to the right
{ text: 'Fake Name Button' }
]
});
Ext.create('Ext.container.Container', {
layout: 'fit',
width : 700,
renderTo: Ext.getBody(),
items: [toolbar]
});
var image = Ext.create('Ext.Img', {
x: 0,
y: -25,
maxWidth: 70,
src: 'https://twimg0-a.akamaihd.net/profile_images/1471554494/swel.png'
});
Ext.create('Ext.container.Container', {
layout: {
type: 'absolute'
},
renderTo: Ext.getBody(),
items: [image]
});
http://jsfiddle.net/alexrom7/33cP8/1/
This solution is not so pretty, but it might work.

Resources