int rowCount = gridProcessor.getRowCount();
Element tableElement = document.createElement("table");
tableElement.setAttribute("id", elementId);
CssStyle tableCssStyle = new CssStyle();
tableCssStyle.setAttribute("border-collapse", "collapse");
Insets gridInsets = (Insets) grid.getRenderProperty(Grid.PROPERTY_INSETS);
String defaultInsetsAttributeValue = gridInsets == null
? "0px" : InsetsRender.renderCssAttributeValue(gridInsets);
ColorRender.renderToStyle(tableCssStyle, component);
FontRender.renderToStyle(tableCssStyle, component);
BorderRender.renderToStyle(tableCssStyle, border);
ExtentRender.renderToStyle(tableCssStyle, "height", (Extent) grid.getRenderProperty(Grid.PROPERTY_HEIGHT));
Extent width = (Extent) grid.getRenderProperty(Grid.PROPERTY_WIDTH);
boolean render100PercentWidthWorkaround = false;
if (rc.getContainerInstance().getClientProperties().getBoolean(
ClientProperties.QUIRK_IE_TABLE_PERCENT_WIDTH_SCROLLBAR_ERROR)) {
if (width != null && width.getUnits() == Extent.PERCENT && width.getValue() == 100) {
width = null;
render100PercentWidthWorkaround = true;
}
}
ExtentRender.renderToStyle(tableCssStyle, "width", width);
Extent borderSize = border == null ? null : border.getSize();
if (borderSize != null) {
if (!rc.getContainerInstance().getClientProperties().getBoolean(ClientProperties.QUIRK_CSS_BORDER_COLLAPSE_INSIDE)) {
tableCssStyle.setAttribute("margin", ExtentRender.renderCssAttributeValueHalf(borderSize));
}
}
tableElement.setAttribute("style", tableCssStyle.renderInline());
parentNode.appendChild(tableElement);
boolean someColumnsHaveWidths = false;
for (int i = 0; i < columnCount; ++i) {
if (gridProcessor.getColumnWidth(i) != null) {
someColumnsHaveWidths = true;
}
}
if (someColumnsHaveWidths) {
Element colGroupElement = document.createElement("colgroup");
tableElement.appendChild(colGroupElement);
for (int i = 0; i < columnCount; ++i) {
Element colElement = document.createElement("col");
Extent columnWidth = gridProcessor.getColumnWidth(i);
if (columnWidth != null) {
colElement.setAttribute("style", "width:" + ExtentRender.renderCssAttributeValue(columnWidth));
}
colGroupElement.appendChild(colElement);
}
}
Element tbodyElement = document.createElement("tbody");
tbodyElement.setAttribute("id", elementId + "_tbody");
tableElement.appendChild(tbodyElement);
Set renderedCells = new HashSet();
for (int rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
Element trElement = document.createElement("tr");
trElement.setAttribute("id", elementId + "_tr_" + rowIndex);
if (gridProcessor.getRowHeight(rowIndex) != null) {
trElement.setAttribute("style", "height:" + ExtentRender.renderCssAttributeValue(gridProcessor.getRowHeight(rowIndex)));
}
tbodyElement.appendChild(trElement);
for (int columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
Component cell = gridProcessor.getContent(columnIndex, rowIndex);
if (cell == null) {
Element tdElement = document.createElement("td");
trElement.appendChild(tdElement);
continue;
}
if (renderedCells.contains(cell)) {
// Cell already rendered.
continue;
}
renderedCells.add(cell);
Element tdElement = document.createElement("td");
tdElement.setAttribute("id", elementId + "_td_" + ContainerInstance.getElementId(cell));
trElement.appendChild(tdElement);
int columnSpan = gridProcessor.getColumnSpan(columnIndex, rowIndex);
if (columnSpan > 1) {
tdElement.setAttribute("colspan", Integer.toString(columnSpan));
}
int rowSpan = gridProcessor.getRowSpan(columnIndex, rowIndex);
if (rowSpan > 1) {
tdElement.setAttribute("rowspan", Integer.toString(rowSpan));
}
CssStyle tdCssStyle = new CssStyle();
BorderRender.renderToStyle(tdCssStyle, (Border) grid.getRenderProperty(Grid.PROPERTY_BORDER));
CellLayoutDataRender.renderToElementAndStyle(tdElement, tdCssStyle, cell, getLayoutData(cell),
defaultInsetsAttributeValue);
CellLayoutDataRender.renderBackgroundImageToStyle(tdCssStyle, rc, this, grid, cell);
tdElement.setAttribute("style", tdCssStyle.renderInline());
if (rowIndex == 0 && render100PercentWidthWorkaround) {
// Render string of "sizing dots" in first cell.
Element sizingDivElement = document.createElement("div");
sizingDivElement.setAttribute("style", "font-size:50px;height:0px;overflow:hidden;");