When adjusting the width of a vertical header in a grid to 50px, the header text disappears unless manually dragged to the left. How can I ensure the header text remains visible even with a smaller header size?
Consider the following code snippet:
{ text: 'Phone' dataIndex: 'phone', cls: 'grid-header-phone' }
To set a smaller width for the header:
{ text: 'Phone', width: 50, dataIndex: 'phone', cls: 'grid-header-phone' }
Here's a working example.
Below is the JavaScript code being used:
Ext.application({
name : 'Fiddle',
launch : function() {
var store = Ext.create('Ext.data.Store', {
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Lisa', "email":"example1@example.com", "phone":"555-111-1224" },
{ 'name': 'Bart', "email":"example2@example.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"example3@example.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"example4@example.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: store,
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', width: 50, dataIndex: 'phone', cls: 'grid-header-phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
}
});
And here is the corresponding CSS code:
.grid-header-phone .x-column-header-text {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
/* transform doesn't work on inline elements */
display: inline-block;
/* need to hard code a height for this to work */
/* you could use Ext.util.TextMetrics if you needed to dynamically determine the text size */
height: 40px;
}
.x-ie8 .grid-header-phone .x-column-header-text {
/* IE8 doesn't have css transform */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
}