Here's a problem or at least a misbehavior I encountered when playing around with a grid which is rendered intto a container of 100% window width.
The container size is known at rendering time, but when the window gets *resized*, the grid doesn't resize its content - but it should, cause the container dimensions are known after window resize and the monitorWindowResize flag is set.
I've read the limits and docu well:
* The container MUST have some type of size defined for the grid to fill.
- Actually the size is rendered correctly the frist time, the container width is defined by the window width.
Is this behavior correct?
Other improvement: It should be possible to set the column width in percent (of the container width).
The container width is known, so the column width can be calculated.
Regards,
Marco
Here's the simple test code (based on the grid examples):
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>100% Grid Test</title>
<script type="text/javascript" src="../../adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>
<script type="text/javascript" src="../../package/util.js"></script>
<link rel="stylesheet" type="text/css" href="../../resources/css/reset-min.css" />
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
</head>
<body>
<p>This example sets the container to 100% window width. The grid should resize
if the window is resized, all dimensions of the grid are known:</p>
<div id="test" style="border: 1px solid #00B; margin:10px;">
Small test container for 100% window width.
</div>
<br />
<div id="container" style="border: 1px solid #00B; margin:10px;">
<div id="grid"></div>
</div>
<script type="text/javascript">
var Example = {
init : function(){
// some test data
var myData = [
['blue', 'fix', 'dog'],
['red', 'var', 'cat'],
['gray', 'fix', 'bird'],
['yellow', 'var', 'big bird']
];
var ds = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(myData),
reader: new Ext.data.ArrayReader({}, [
{name: 'color'},
{name: 'type'},
{name: 'animal'}
])
});
ds.load();
// simple colum model
var colModel = new Ext.grid.ColumnModel([
{id: 'color', header:"Color", width: 160, dataIndex: 'color'},
{id: 'type', header: "Type", width: 75, dataIndex: 'type'},
{id: 'animal', header: "Animal", width: 75, dataIndex: 'animal'}
]);
// create the Grid
var grid = new Ext.grid.Grid('grid', {
ds: ds,
cm: colModel,
monitorWindowResize: true,
autoExpandColumn: 'animal'
});
grid.render();
grid.getSelectionModel().selectFirstRow();
}
};
Ext.onReady(Example.init, Example);
</script>
</body>
</html>
Tested with Ext1.1RC1 / IE7, FF2, OP9