PDA

View Full Version : Grid overflow-x hidden issue in firefox



meehigh
19 Aug 2010, 7:00 AM
Hello. I am trying to synchronize horizontal scrolling in two grids. On the bodyscroll event of the second grid I set the scrollLeft of the first grid. It apparently works well, except that when I scroll vertically the first grid, its left scroll position is reset to 0. This only happens in Firefox.
The code below illustrates this problem. Please help.



<html>
<head>

<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<style type="text/css">
.myFirstGrid .x-grid3-scroller{
overflow-x: hidden !important;
}

.mySecondGrid .x-grid3-scroller{

}
</style>
<script type="text/javascript">
Ext.onReady(function(){

myData = [
['3m Co',71.72,0.02,0.03],
['Alcoa Inc',29.01,0.42,1.47],
['Altria Group Inc',83.81,0.28,0.34],
['American Express Company',52.55,0.01,0.02],
['American International Group, Inc.',64.13,0.31,0.49],
['AT&T Inc.',31.61,-0.48,-1.54],
['Boeing Co.',75.43,0.53,0.71],
['Caterpillar Inc.',67.27,0.92,1.39],
['Citigroup, Inc.',49.37,0.02,0.04],
['E.I. du Pont de Nemours and Company',40.48,0.51,1.28],
['Exxon Mobil Corp',68.1,-0.43,-0.64],
['General Electric Company',34.14,-0.08,-0.23],
['General Motors Corporation',30.27,1.09,3.74],
['Hewlett-Packard Co.',36.53,-0.03,-0.08],
['Honeywell Intl Inc',38.77,0.05,0.13],
['Intel Corporation',19.88,0.31,1.58],
['International Business Machines',81.41,0.44,0.54],
['Johnson & Johnson',64.72,0.06,0.09],
['JP Morgan & Chase & Co',45.73,0.07,0.15],
['McDonald\'s Corporation',36.76,0.86,2.40],
['Merck & Co., Inc.',40.96,0.41,1.01],
['Microsoft Corporation',25.84,0.14,0.54],
['Pfizer Inc',27.96,0.4,1.45],
['The Coca-Cola Company',45.07,0.26,0.58],
['The Home Depot, Inc.',34.64,0.35,1.02],
['The Procter & Gamble Company',61.91,0.01,0.02],
['United Technologies Corporation',63.26,0.55,0.88],
['Verizon Communications',35.57,0.39,1.11],
['Wal-Mart Stores, Inc.',45.45,0.73,1.63]
];

var myColumns = [
{id:'company',header: 'Company', width: 100, dataIndex: 'company'},
{header: 'Price', width: 100, dataIndex: 'price'},
{header: 'Change', width: 100, dataIndex: 'change'},
{header: '% Change', width: 100, dataIndex: 'pctChange'}
];

var myFields = [
{name: 'company'},
{name: 'price', type: 'float'},
{name: 'change', type: 'float'},
{name: 'pctChange', type: 'float'}
];

var myFirstStore = new Ext.data.ArrayStore({
data: myData,
fields: myFields,
autoload: true,
});

var mySecondStore = new Ext.data.ArrayStore({
data: [myData[1]],
fields: myFields,
autoload: true,
});

var myFirstGrid = new Ext.grid.GridPanel({
cls: 'myFirstGrid',
border: false,
store: myFirstStore,
renderTo: Ext.getBody(),
columns: myColumns,
height: 100,
width: 300
});

var mySecondGrid = new Ext.grid.GridPanel({
cls: 'mySecondGrid',
hideHeaders: true,
store: mySecondStore,
renderTo: Ext.getBody(),
columns: myColumns,
height: 41,
width: 300
});

myFirstGrid.on('columnresize',function(colIndex,newSize){
mySecondGrid.getColumnModel().setColumnWidth(colIndex,newSize);
},this);

myFirstGrid.on('columnmove',function(colIndex,newSize){
mySecondGrid.reconfigure(myStore,myFirstGrid.getColumnModel());
},this);

mySecondGrid.on('bodyscroll',function(scrollLeft,scrollTop){
myFirstGrid.getView().scroller.dom.scrollLeft = scrollLeft;
},this);

});
</script>
</head>

<body>
</body>

</html>