PDA

View Full Version : Chaging the width of grid's columns



webfriend13
1 Jun 2012, 12:32 AM
Hi All,

I have two ExtJS 4.1 grids placed over each other. I am hiding the column headers in the second grid. When user changes the width of any column in the first grid, I want to resize the columns in second grid as well.

I am using following code on column resize event of first grid.

While this code is working fine, the script is taking long time to execute. I wonder if there is better way to achieve the same:-?. I am using groupingFeature as well.




columnresize: function (container, column, width, eOpts) {
for (var i = 0; i < grid.getView().getHeaderCt().getColumnCount(); i++) {
var gridColumns = grid.getView().getHeaderCt().getGridColumns();
var secondGridColumns = secondGrid.getView().getHeaderCt().getGridColumns();
var colWidth = gridColumns[i].getWidth();
secondGridColumns[i].setWidth(colWidth);
}
}

sword-it
1 Jun 2012, 4:25 AM
HI!

Try This:-




columnresize: function (container, column, width, eOpts) {
var gridColunms=grid.getView().getHeaderCt().getColumnCount()
, secondGridColumns = secondGrid.getView().getHeaderCt().getGridColumns();
for (var i = 0; i < gridColunms; i++) {
var colWidth = gridColumns[i].getWidth();
secondGridColumns[i].setWidth(colWidth);
}
}