Cannot create split region between two panels in extjs - extjs

I have used split: true and it worked until I had the following situation:
centerContent = new Ext.Panel
({
layout: 'border',
split:true,
stateful:true,
border:false,
items:
[
{
region:'center',
margins:'0 0 0 0',
autoScroll:true,
split: true,
items:
[
{
region: 'north',
height: 250,
minSize: 150,
frame:false,
border:false,
layout:'fit',
items: blah
},
{
title:'Graph',
region:'south',
margins:'0 0 0 0',
collapsible: true,
split:true,
frame:false,
border:false,
height: 500,
minSize: 250,
layout:'fit',
items: anotherBlah
}
]
}
]
});
I tried to put split: true everywhere, but still no result. To illustrate the result of this code, I have attached a picture:
The north region has no title, but it renders to the item: blah. South region has title 'Graph' as you can see from the picture. I want to be able to split/drag down south region from north whenever necessary. But that "split tool" will not show up.
Do you know what am I missing?

You can't have border layout and auto scroll in the same container. The reason is that the border layout will fit its children component to the available space, and so they will never overflow.
So, in order to achieve what you want, you need an inner container with a fixed height (so that it overflows its parent) in a container with autoScroll. Then you apply the border layout to that inner container.
Example (jsFiddle):
Ext.widget('container', {
renderTo: Ext.getBody()
// the 300px container contains a 500px child: it will scroll
,width: 300
,height: 300
,autoScroll: true
,items: [{
xtype: 'container'
,height: 500
// the 500px container has border layout
,layout: 'border'
,items: [{
// you are required to have a center region, so use center and south
title: 'Center'
,region: 'center'
,height: 200
},{
title: 'South'
,region: 'south'
,split: true
,height: 300
}]
}]
});

Related

ExtJS: east/west region to occupy available space when other regions are not present

Iam using border layout for my application.I want to make east/west region to occupy the available space whenever other regions are hidden or not present.
For example if east and center regions are there, if center region is made hidden, automatically east region should occupy the space available.
Please suggest your ideas to achieve this.
Thank You.
I suggest to use cleverly the flex property.
Here is a Sencha Fiddle for you
Ext.create('Ext.panel.Panel', {
width: 500,
height: 300,
title: 'Border Layout',
layout: 'border',
items: [{
title: 'South Region is resizable',
region: 'south', // position for region
xtype: 'panel',
height: 100,
split: true, // enable resizing
margins: '0 5 5 5'
}, {
// xtype: 'panel' implied by default
title: 'West Region is collapsible',
region: 'west',
xtype: 'panel',
layout: 'fit',
flex:100,
collapsible:true,
id: 'west-region-container',
layout: 'fit',
html:'Content of the west panel'
}, {
title: 'Center Region is collapsible',
region: 'center',
xtype: 'panel',
flex:100,
layout: 'fit',
collapsible:true,
html:'Content of the center'
}],
renderTo: Ext.getBody()
});

ExtJS viewport panel

I have EXTJS panel inside a viewport east region,
var viewport = new Ext.Viewport({
layout: 'border',
id:'mainviewport',
monitorResize:false,
items: [{
region: 'east',
xtype: 'panel',
id:'east-panel',
header : false,
headerAsText: false,
title: 'east panel',
collapsible: true,
split: true,
minSize: 305,
maxSize: east_panel_width,
margins: '53 0 0 0',
cmargins:'53 0 0 0',
collapsed: true,
autoScroll: true,
layout: 'fit',
html:'<div id="abc" style="height:100%;overflow-x: hidden; overflow-y: auto;"></div>'
}]
});
I dont want the title header so i gave the property header: false, headerAsText: false the title bar get hided, but i want the collapsible option for this. How can i get that collapsible function.
Is that possible to hide only the title text and the background css of that, without distrubing the collapsible panel extender option.
Thanks in advance.
Even with header: false, headerAsText: false you have an arrow in the middle of the splitter bar. It works as a collapsing control of the panel.

extjs get height of viewport panel

I want a specific height(600px,etc) of the middle content on page load:
Right now I have something similar to:
[_____________Header________________]
[Left Sidebar] [Middle Content Panel] [Right Sidebar]
[_____________Footer_________________]
Part of the code:
var viewport = new Ext.Viewport({
layout: 'border',
id: 'parent_container',
items: [{
region: 'north',
contentEl: 'header',
border: false
}, {
region: 'west',
id: 'left_sidebar_panel',
split: true,
width: 200,
minSize: 200,
maxSize: 400,
autoScroll: true,
contentEl: 'sidebar_container',
border: false
},{
region: 'center',
id: 'middle_content_panel',
layout: 'border',
border: false,
items: [{
region: 'north',
contentEl: 'main_content_header',
border: false
}...
Is there anyway to force middle_content_panel to have a specific height on page load/window expand? Or a way to grab the height of it with javascript some other way.
First you have to define your center content as variable
For example: var center= new Ext.Panel({
...
});
You can use setHeight Method center.setHeight(600);
From Documentation:

ExtJS: Autoscroll vertical FormPanels added to panel

I'm writing an app where I have a BorderLayout for the entire page. In the south part I have a Panel to which I add FormPanels. I would like to be able to scroll that Panel so I can scroll through the FormPanels.
So far, nothing I've found from searches has helped. I don't quite understand what ExtJS requires in terms of the combination of LayoutManagers, setting the size and setting AutoScroll.
Any partial tips will be gratefully followed up.
A code snippet:
new Ext.Viewport({
layout: "border",
items: [{
region: "north",
contentEl: "title",
height: 50
}, {
region: "center",
id: "mappanel",
title: "Map",
xtype: "gx_mappanel",
map: map,
layers: [layer],
extent: extent,
split: true,
tbar: toolbarItems
}, {
region: "east",
title: "Details",
width: 300,
split: true,
id: "east-panel",
laout: 'fit'
}, {
region: "south",
id: "south-panel",
height: 200
}, {
region: "west",
id: "west-panel",
width: 300
}]
});
matchedTrailJunctionsPanel = new Ext.Panel({
title: "Matched Trail Junctions2",
id: "matched-trail-junctions",
autoScroll:true
//layout: 'anchor'
});
var southPanel = Ext.getCmp('south-panel');
southPanel.add(matchedTrailJunctionsPanel);
southPanel.doLayout();
createTrailJunctionPanel = function(trailJunction) {
var trailJunctionPanel = new Ext.form.FormPanel({
labelWidth: 75,
width: 350,
defaultType: 'textfield',
items: [{
fieldLabel: 'Junction Name',
name: 'junction-name'
}],
autoScroll:true,
//anchor: '100% 100%',
height: 100
});
matchedTrailJunctionsPanel.add(trailJunctionPanel);
if(trailJunction.publicTrailSegments.length == 0) {
matchedTrailJunctionsPanel.add(new Ext.form.Label({text: 'No public trails matched'}));
} else {
var grid = new Ext.grid.GridPanel({
store: mapMatchObjectStore,
columns: [
{id:'publicTrailSegment',header: 'Trail', width: 160, sortable: true, dataIndex: 'publicTrailSegment'}
],
stripeRows: true,
autoExpandColumn: 'publicTrailSegment',
height: 350,
width: 600,
title: 'Matched Trail Junctions'
});
matchedTrailJunctionsPanel.add(grid);
}
matchedTrailJunctionsPanel.doLayout();
}
Your south panel is the main container for your components, so it should be autoScroll:true and you should be adding both your form and grid into it. You can't really add a grid into a FormPanel directly as it's not a form field (you'd have to wrap it as a Field or implement some of Field's interface). It may work with south having no layout (the browser should just stick the grid directly after the form) but generally it's better to specify an appropriate layout (vbox would be a good one in this case).
The containing panel must have the height set. The contained panels must either have the height set or autoHeight: true set.

How to create a split region with autoheights in ExtJS

I would have thought this would be quite simple. alas it seems nothing about ExtJS is simple.
I need to split the center region of a border layout and have both the top and bottom panels fill the center region when the page resizes.
As it stands, I can only figure out how to set absolute sizes for the panels.
Here's the code generated using ExtJS Gui Builder
/* This file is created or modified with
* Ext.ux.guid.plugin.GuiDesigner (v2.1.0)
*/
{
layout: "border",
items: [{
region: "center",
title: "map",
items: [{
xtype: "panel",
title: "Panel",
autoHeight: true,
split: true,
height: 100
}, {
xtype: "panel",
title: "Panel",
autoHeight: true,
split: true,
height: 300
}]
}, {
region: "north",
split: true,
height: 100
}, {
region: "west",
width: 300,
split: true,
collapsible: true,
title: "Gazetter Explorer"
}]
}
First off, autoheight means that the container will collapse to the size of the content and its dimensions will be managed by the browser (not by Ext). This is almost never what you want in an app UI.
Your center region should have some type of layout specified. You could "split" it by giving it layout: 'border' and giving it a center and a north/south panel. However, to mimic an "auto height" type of layout, you'd probably want to go with a vbox layout (Ext 3.x) with two child panels that each stretch to take up 50% (or whatever you want) of the space.

Resources