The items should automatically fit their border layout regions.
I just complemented your code with a few things to make it work (example grid data, calling .show()
on the main window etc.) and ran it on Sencha Fiddle with Ext JS 4.2.1 without any problems, especially there are no undesired scroll bars.
Here is the full example source code:
Ext.application({
name: 'Border Layout',
launch: function() {
// create the Data Store
var store = Ext.create('Ext.data.Store', {
model: 'Person',
autoLoad: true,
fields: ['firstName', 'lastName'],
proxy: {
type: 'memory',
data: [
["Anton", "Mainzel"],
["Bertie", "Mainzel"],
["Connie", "Mainzel"],
["Det", "Mainzel"],
["Eddie", "Mainzel"]
],
reader: {
type: 'array'
}
}
});
var grid = Ext.create('Ext.grid.Panel', {
region: 'west',
width: 120,
split: true,
store: store,
columns: [{
text: "First",
width: 120,
dataIndex: 'firstName'
}, {
text: "Last",
width: 120,
dataIndex: 'lastName'
}]
});
var chartContainer = Ext.create('Ext.Panel', { // a panel contains a pie chart
region: 'center',
bodyStyle: 'background-color:green; color:white',
html: '<p>Center</p>'
});
var mainPanel = Ext.create('Ext.Panel', { // my main container panel
layout: 'border',
items: [grid, chartContainer]
});
Ext.create('Ext.Window', { // I want to render this main panel inside a window
layout: 'fit',
width: 950,
height: 500,
items: [mainPanel]
}).show();
}
});
grid
andchartContainer
to be fit insidemainPanel
? Because you are applying a border layout to them. The fit layout is only being applied tomainPanel
(it will be fit to the window it is inside) – forgivenson