int[] columnWidths = getColumnWidths();
// root builder
SafeHtmlBuilder buf = new SafeHtmlBuilder();
final SafeStyles rowStyles = SafeStylesUtils.fromTrustedString("width: " + getTotalWidth() + "px;");
final String unselectableClass = unselectable;
final String rowAltClass = styles.rowAlt();
final String rowDirtyClass = styles.rowDirty();
final String cellClass = styles.cell() + " " + states.cell();
final String cellInnerClass = styles.cellInner() + " " + states.cellInner();
final String cellFirstClass = "x-grid-cell-first";
final String cellLastClass = "x-grid-cell-last";
final String cellDirty = styles.cellDirty();
final String rowWrap = styles.rowWrap() + " " + states.rowWrap();
final String rowBody = styles.rowBody() + " " + states.rowBody();
final String rowBodyRow = states.rowBodyRow();
// loop over all rows
for (int j = 0; j < rows.size(); j++) {
M model = rows.get(j);
ListStore<M>.Record r = ds.hasRecord(model) ? ds.getRecord(model) : null;
int rowBodyColSpanCount = colCount;
if (enableRowBody) {
for (ColumnConfig<M, ?> c : cm.getColumns()) {
if (c instanceof RowExpander) {
rowBodyColSpanCount--;
}
}
}
int rowIndex = (j + startRow);
String rowClasses = styles.row() + " " + states.row();
if (!selectable) {
rowClasses += " " + unselectableClass;
}
if (isStripeRows() && ((rowIndex + 1) % 2 == 0)) {
rowClasses += " " + rowAltClass;
}
if (showDirtyCells && r != null && r.isDirty()) {
rowClasses += " " + rowDirtyClass;
}
if (viewConfig != null) {
rowClasses += " " + viewConfig.getRowStyle(model, rowIndex);
}
SafeHtmlBuilder trBuilder = new SafeHtmlBuilder();
// loop each cell per row
for (int i = 0; i < colCount; i++) {
SafeHtml rv = getRenderedValue(rowIndex, i, model, r);
ColumnConfig<M, ?> columnConfig = cm.getColumn(i);
ColumnData columnData = cs.get(i);
String cellClasses = cellClass;
if (i == 0) {
cellClasses += " " + cellFirstClass;
} else if (i == last) {
cellClasses += " " + cellLastClass;
}
String cellInnerClasses = cellInnerClass;
if (columnConfig.getColumnTextClassName() != null) {
cellInnerClasses += " " + columnConfig.getColumnTextClassName();
}
if (!columnConfig.isCellPadding()) {
cellInnerClasses += " " + styles.noPadding();
}
if (columnData.getClassNames() != null) {
cellClasses += " " + columnData.getClassNames();
}
if (columnConfig.getCellClassName() != null) {
cellClasses += " " + columnConfig.getCellClassName();
}
if (showDirtyCells && r != null && r.getChange(columnConfig.getValueProvider()) != null) {
cellClasses += " " + cellDirty;
}
if (viewConfig != null) {
cellClasses += " " + viewConfig.getColStyle(model, cm.getValueProvider(i), rowIndex, i);
}
final SafeStyles cellStyles = columnData.getStyles();
final SafeHtml tdContent;
if (enableRowBody && i == 0) {
tdContent = tpls.tdRowSpan(i, cellClasses, cellStyles, rowBodyRowSpan, cellInnerClasses, rv);
} else {