FlexCellFormatter class
FlexTable-specific implementation of {@link HTMLTable.CellFormatter}. The formatter retrieved from {@link HTMLTable#getCellFormatter()} may be cast to this class.
class FlexCellFormatter extends CellFormatter { FlexCellFormatter(HtmlTable table) : super(table); /** * Gets the column span for the given cell. This is the number of logical * columns covered by the cell. * * @param row the cell's row * @param column the cell's column * @return the cell's column span * @throws IndexOutOfBoundsException */ int getColSpan(int row, int column) { return Dom.getElementPropertyInt(getElement(row, column), "colSpan"); } /** * Gets the row span for the given cell. This is the number of logical rows * covered by the cell. * * @param row the cell's row * @param column the cell's column * @return the cell's row span * @throws IndexOutOfBoundsException */ int getRowSpan(int row, int column) { return Dom.getElementPropertyInt(getElement(row, column), "rowSpan"); } /** * Sets the column span for the given cell. This is the number of logical * columns covered by the cell. * * @param row the cell's row * @param column the cell's column * @param colSpan the cell's column span * @throws IndexOutOfBoundsException */ void setColSpan(int row, int column, int colSpan) { Dom.setElementPropertyInt(ensureElement(row, column), "colSpan", colSpan); } /** * Sets the row span for the given cell. This is the number of logical rows * covered by the cell. * * @param row the cell's row * @param column the cell's column * @param rowSpan the cell's row span * @throws IndexOutOfBoundsException */ void setRowSpan(int row, int column, int rowSpan) { Dom.setElementPropertyInt(ensureElement(row, column), "rowSpan", rowSpan); } }
Extends
CellFormatter > FlexCellFormatter
Constructors
Methods
void addStyleName(int row, int column, String styleName) #
Adds a style to the specified cell.
@param row the cell's row @param column the cell's column @param styleName the style name to be added @see UiObject#addStyleName(String)
void addStyleName(int row, int column, String styleName) { _table.prepareCell(row, column); dart_html.Element td = getCellElement(_table.bodyElem, row, column); UiObject.manageElementStyleName(td, styleName, true); }
Element ensureElement(int row, int column) #
Gets the element associated with a cell. If it does not exist and the subtype allows creation of elements, creates it.
@param row the cell's row @param column the cell's column @return the cell's element @throws IndexOutOfBoundsException
dart_html.Element ensureElement(int row, int column) { _table.prepareCell(row, column); return getCellElement(_table.bodyElem, row, column); }
String getAttr(int row, int column, String attr) #
Convenience methods to get an attribute on a cell.
@param row cell's row @param column cell's column @param attr attribute to get @return the attribute's value @throws IndexOutOfBoundsException
String getAttr(int row, int column, String attr) { dart_html.Element elem = getElement(row, column); return elem.attributes[attr]; }
Element getCellElement(Element table, int row, int col) #
Native method to get a cell's element.
@param table the table element @param row the row of the cell @param col the column of the cell @return the element
dart_html.Element getCellElement(dart_html.Element table, int row, int col) { if (table is! dart_html.TableElement) { table = table.parent as dart_html.TableElement; } assert (table is dart_html.TableElement); return (table as dart_html.TableElement).rows[row].cells[col]; }
int getColSpan(int row, int column) #
Gets the column span for the given cell. This is the number of logical columns covered by the cell.
@param row the cell's row @param column the cell's column @return the cell's column span @throws IndexOutOfBoundsException
int getColSpan(int row, int column) { return Dom.getElementPropertyInt(getElement(row, column), "colSpan"); }
Element getElement(int row, int column) #
Gets the TD element representing the specified cell.
@param row the row of the cell to be retrieved @param column the column of the cell to be retrieved @return the column's TD element @throws IndexOutOfBoundsException
dart_html.Element getElement(int row, int column) { _table.checkCellBounds(row, column); return getCellElement(_table.bodyElem, row, column); }
Element getRawElement(int row, int column) #
Gets the TD element representing the specified cell unsafely (meaning that it doesn't ensure that <code>row</code> and <code>column</code> are valid).
@param row the row of the cell to be retrieved @param column the column of the cell to be retrieved @return the cell's TD element
dart_html.Element getRawElement(int row, int column) { return getCellElement(_table.bodyElem, row, column); }
int getRowSpan(int row, int column) #
Gets the row span for the given cell. This is the number of logical rows covered by the cell.
@param row the cell's row @param column the cell's column @return the cell's row span @throws IndexOutOfBoundsException
int getRowSpan(int row, int column) { return Dom.getElementPropertyInt(getElement(row, column), "rowSpan"); }
String getStyleName(int row, int column) #
Gets the style of a specified cell.
@param row the cell's row @param column the cell's column @see UiObject#getStyleName() @return returns the style name @throws IndexOutOfBoundsException
String getStyleName(int row, int column) { return UiObject.getElementStyleName(getElement(row, column)); }
String getStylePrimaryName(int row, int column) #
Gets the primary style of a specified cell.
@param row the cell's row @param column the cell's column @see UiObject#getStylePrimaryName() @return returns the style name @throws IndexOutOfBoundsException
String getStylePrimaryName(int row, int column) { return UiObject.getElementStylePrimaryName(getElement(row, column)); }
bool isVisible(int row, int column) #
Determines whether or not this cell is visible.
@param row the row of the cell whose visibility is to be set @param column the column of the cell whose visibility is to be set @return <code>true</code> if the object is visible
bool isVisible(int row, int column) { dart_html.Element e = getElement(row, column); return UiObject.isVisible(e); }
void removeStyleName(int row, int column, String styleName) #
Removes a style from the specified cell.
@param row the cell's row @param column the cell's column @param styleName the style name to be removed @see UiObject#removeStyleName(String) @throws IndexOutOfBoundsException
void removeStyleName(int row, int column, String styleName) { _table.checkCellBounds(row, column); dart_html.Element td = getCellElement(_table.bodyElem, row, column); UiObject.manageElementStyleName(td, styleName, false); }
void setAlignment(int row, int column, HorizontalAlignmentConstant hAlign, VerticalAlignmentConstant vAlign) #
Sets the horizontal and vertical alignment of the specified cell's contents.
@param row the row of the cell whose alignment is to be set @param column the column of the cell whose alignment is to be set @param hAlign the cell's new horizontal alignment as specified in
{@link HasHorizontalAlignment}
@param vAlign the cell's new vertical alignment as specified in
{@link HasVerticalAlignment}
@throws IndexOutOfBoundsException
void setAlignment(int row, int column, HorizontalAlignmentConstant hAlign, VerticalAlignmentConstant vAlign) { setHorizontalAlignment(row, column, hAlign); setVerticalAlignment(row, column, vAlign); }
void setAttr(int row, int column, String attrName, String value) #
Convenience methods to set an attribute on a cell.
@param row cell's row @param column cell's column @param attrName attribute to set @param value value to set @throws IndexOutOfBoundsException
void setAttr(int row, int column, String attrName, String value) { dart_html.Element elem = ensureElement(row, column); Dom.setElementAttribute(elem, attrName, value); }
void setColSpan(int row, int column, int colSpan) #
Sets the column span for the given cell. This is the number of logical columns covered by the cell.
@param row the cell's row @param column the cell's column @param colSpan the cell's column span @throws IndexOutOfBoundsException
void setColSpan(int row, int column, int colSpan) { Dom.setElementPropertyInt(ensureElement(row, column), "colSpan", colSpan); }
void setHeight(int row, int column, String height) #
Sets the height of the specified cell.
@param row the row of the cell whose height is to be set @param column the column of the cell whose height is to be set @param height the cell's new height, in CSS units @throws IndexOutOfBoundsException
void setHeight(int row, int column, String height) { _table.prepareCell(row, column); dart_html.Element elem = getCellElement(_table.bodyElem, row, column); Dom.setElementProperty(elem, "height", height); }
void setHorizontalAlignment(int row, int column, HorizontalAlignmentConstant align) #
Sets the horizontal alignment of the specified cell.
@param row the row of the cell whose alignment is to be set @param column the column of the cell whose alignment is to be set @param align the cell's new horizontal alignment as specified in
{@link HasHorizontalAlignment}.
@throws IndexOutOfBoundsException
void setHorizontalAlignment(int row, int column, HorizontalAlignmentConstant align) { _table.prepareCell(row, column); dart_html.Element elem = getCellElement(_table.bodyElem, row, column); Dom.setElementProperty(elem, "align", align.getTextAlignString()); }
void setRowSpan(int row, int column, int rowSpan) #
Sets the row span for the given cell. This is the number of logical rows covered by the cell.
@param row the cell's row @param column the cell's column @param rowSpan the cell's row span @throws IndexOutOfBoundsException
void setRowSpan(int row, int column, int rowSpan) { Dom.setElementPropertyInt(ensureElement(row, column), "rowSpan", rowSpan); }
void setStyleName(int row, int column, String styleName) #
Sets the style name associated with the specified cell.
@param row the row of the cell whose style name is to be set @param column the column of the cell whose style name is to be set @param styleName the new style name @see UiObject#setStyleName(String) @throws IndexOutOfBoundsException
void setStyleName(int row, int column, String styleName) { _table.prepareCell(row, column); UiObject.setElementStyleName(getCellElement(_table.bodyElem, row, column), styleName); }
void setStylePrimaryName(int row, int column, String styleName) #
Sets the primary style name associated with the specified cell.
@param row the row of the cell whose style name is to be set @param column the column of the cell whose style name is to be set @param styleName the new style name @see UiObject#setStylePrimaryName(String) @throws IndexOutOfBoundsException
void setStylePrimaryName(int row, int column, String styleName) { UiObject.setElementStylePrimaryName(getCellElement(_table.bodyElem, row, column), styleName); }
void setVerticalAlignment(int row, int column, VerticalAlignmentConstant align) #
Sets the vertical alignment of the specified cell.
@param row the row of the cell whose alignment is to be set @param column the column of the cell whose alignment is to be set @param align the cell's new vertical alignment as specified in
{@link HasVerticalAlignment}.
@throws IndexOutOfBoundsException
void setVerticalAlignment(int row, int column, VerticalAlignmentConstant align) { _table.prepareCell(row, column); Dom.setStyleAttribute(getCellElement(_table.bodyElem, row, column), "verticalAlign", align.getVerticalAlignString()); }
void setVisible(int row, int column, bool visible) #
Sets whether this cell is visible via the display style property. The other cells in the row will all shift left to fill the cell's space. So, for example a table with (0,1,2) will become (1,2) if cell 1 is hidden.
@param row the row of the cell whose visibility is to be set @param column the column of the cell whose visibility is to be set @param visible <code>true</code> to show the cell, <code>false</code> to
hide it
void setVisible(int row, int column, bool visible) { dart_html.Element e = ensureElement(row, column); UiObject.setVisible(e, visible); }
void setWidth(int row, int column, String width) #
Sets the width of the specified cell.
@param row the row of the cell whose width is to be set @param column the column of the cell whose width is to be set @param width the cell's new width, in CSS units @throws IndexOutOfBoundsException
void setWidth(int row, int column, String width) { // Give the subclass a chance to prepare the cell. _table.prepareCell(row, column); Dom.setElementProperty(getCellElement(_table.bodyElem, row, column), "width", width); }
void setWordWrap(int row, int column, bool wrap) #
Sets whether the specified cell will allow word wrapping of its contents.
@param row the row of the cell whose word-wrap is to be set @param column the column of the cell whose word-wrap is to be set @param wrap <code>false </code> to disable word wrapping in this cell @throws IndexOutOfBoundsException
void setWordWrap(int row, int column, bool wrap) { _table.prepareCell(row, column); String wrapValue = wrap ? "" : "nowrap"; Dom.setStyleAttribute(getElement(row, column), "whiteSpace", wrapValue); }