PDA

View Full Version : table speedup



si_gee2000
2 Jul 2008, 11:15 AM
Hi Darrell -

been ages since I even had a chance to look at the forum, looks like everything is going well even if I'm still stuck in the dark ages of myGWT. Anyway - got a nice speedup on the table rendering - noticed that you call updateSplits too often on a resize of all cols (like initial drawing).. Don;t know where the code base is now, but if it fits here's my patch for the TableHeader.java file, replaces 3 methods resizeColumns, and resizeColumn plus a new resizeColumn to maintain any compatability. See the comment starting //SG to get the jist.
This applies to the TreeTableHeader too.

Got another on
TreeTableItemUI
too (you call render in the super() call in the contructor, then again after the style sets. I just added a control so render is ignored on call from super, and then called properly at the end.

Got quite a nice boost by doing these. Maybe you already have..?

anyway, here the code patch:


protectedvoid resizeColumn(int index, boolean resizeBody) {
resizeColumn(index, resizeBody, true);
}

protectedvoid resizeColumn(int index, boolean resizeBody, boolean updateSplits) {
TableColumn column = columnModel.getColumn(index);
TableColumnUI ui = getColumnUI(index);
if (column.isHidden()) {
ui.setVisible(false);
return;
} else {
ui.setVisible(true);
}
int w = columnModel.getWidthInPixels(column.index);

if (w != ui.lastWidth) {
Element td = DOM.getParent(ui.getElement());
w -= MyDOM.getBorderWidth(td, Style.LEFT | Style.RIGHT);

MyDOM.setWidth(ui.getElement(), w);

SplitBar splitBar = ui.splitBar;
if (splitBar != null) {
if (column.isResizable()) {
splitBar.setVisible(true);
}
splitBar.setMinSize(column.getMinWidth());
splitBar.setMaxSize(column.getMaxWidth());
splitBar.updateHandle();
}

//SG - don't do this on every resize if resizing all columns

if(updateSplits) {
updateSplitBars();
}

table.getView().resizeCells(index);
}

ui.lastWidth = w;

if (resizeBody) {
table.getView().resize();
}
}

protectedvoid resizeColumns(boolean fireEvent, boolean resizeBody) {
int cols = columnModel.getColumnCount();
int totWidth = 0;
for (int i = 0; i < cols; i++) {
resizeColumn(i, false, false);
}

int tableWidth = table.getOffsetWidth();
if (totWidth < tableWidth) {
MyDOM.setWidth(endColumn.getElement(), tableWidth - totWidth + 25);
} else {
MyDOM.setWidth(endColumn.getElement(), 25);
}
updateSplitBars();

if (resizeBody) {
table.getView().resize();
}

}