Skip to content
Snippets Groups Projects
Commit c8cab5c8 authored by izabel's avatar izabel
Browse files

[LMS-1400] column auto width update

SVN: 15100
parent 9ff03b0f
No related branches found
No related tags found
No related merge requests found
......@@ -69,17 +69,14 @@ class ExtendedGridView extends GridView
protected void onHeaderClickWithShift(Grid<ModelData> pGrid, int column)
{
// WORKAROUND: getHeaderCell takes into account only visible columns
int headerCellIndex = column;
for (int i = 0; i < column; i++)
{
if (pGrid.getColumnModel().getColumn(i).isHidden())
{
headerCellIndex--;
}
}
int margin = 50;
pGrid.getColumnModel().setColumnWidth(column, calculateWidth(pGrid, column) + margin);
}
private int calculateWidth(Grid<ModelData> pGrid, int column)
{
GridView view = pGrid.getView();
Element headerCell = (Element) view.getHeaderCell(headerCellIndex);
Element headerCell = (Element) view.getHeaderCell(calculateHeaderCellIndex(pGrid, column));
TextMetrics tm = TextMetrics.get();
tm.bind(headerCell);
// TODO 2010-03-09, IA: line breaks are ignored
......@@ -95,8 +92,21 @@ class ExtendedGridView extends GridView
max = width;
}
}
int margin = 50;
pGrid.getColumnModel().setColumnWidth(column, max + margin);
return max;
}
private int calculateHeaderCellIndex(Grid<ModelData> pGrid, int column)
{
// WORKAROUND: getHeaderCell takes into account only visible columns
int headerCellIndex = column;
for (int i = 0; i < column; i++)
{
if (pGrid.getColumnModel().getColumn(i).isHidden())
{
headerCellIndex--;
}
}
return headerCellIndex;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment