NAME

HTML::Object::DOM::Element::TableRow - HTML Object DOM TableRow Class

SYNOPSIS

use HTML::Object::DOM::Element::TableRow;
my $tablerow = HTML::Object::DOM::Element::TableRow->new || 
    die( HTML::Object::DOM::Element::TableRow->error, "\n" );

VERSION

v0.2.0

DESCRIPTION

This interface provides special properties and methods (beyond the HTML::Object::DOM::Element interface it also has available to it by inheritance) for manipulating the layout and presentation of rows (i.e. tr) in an HTML table.

INHERITANCE

+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +--------------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::TableRow |
+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +--------------------------------------+

PROPERTIES

Inherits properties from its parent HTML::Object::DOM::Element

cells

Read-only.

Returns a collection containing the cells in the row, but only the ones directly under the row element.

Note that for performance improvement, the collection is cached until changes are made that would affect the results.

Example:

<table id="myTable1">
    <tr>
        <td>
            <table id="myTable2">
                <tr><td></td></tr>
            </table>
        </td>
        <td></td>
    </tr>
</table>

say getElementById('myTable1')->rows->[0]->cells->length; # 2
say getElementById('myTable2')->rows->[0]->cells->length; # 1

See also Mozilla documentation

rowIndex

Read-only.

Returns a long value which gives the logical position of the row within the entire table. If the row is not part of a table, returns undef (-1 under JavaScript).

Example:

<table>
    <thead>
        <tr><th>Item</th>        <th>Price</th></tr>
    </thead>
    <tbody>
        <tr><td>Bananas</td>     <td>$2</td></tr>
        <tr><td>Oranges</td>     <td>$8</td></tr>
        <tr><td>Top Sirloin</td> <td>$20</td></tr>
    </tbody>
    <tfoot>
        <tr><td>Total</td>       <td>$30</td></tr>
    </tfoot>
</table>

Another example:

my $rows = $doc->querySelectorAll('tr');

$rows->forEach(sub
{
    my $row = shift( @_ );
    my $z = $doc->createElement('td');
    $z->textContent = "(row #" . $row->rowIndex . ")";
    row->appendChild($z);
});

See also Mozilla documentation

sectionRowIndex

Read-only.

Returns a long value which gives the logical position of the row within the table section it belongs to. If the row is not part of a section, returns undef (-1 under JavaScript).

See also Mozilla documentation

METHODS

Inherits methods from its parent HTML::Object::DOM::Element

deleteCell

Removes the cell corresponding to the index given in parameter. If the index value is -1 the last cell is removed; if it smaller than -1 or greater than the amount of cells in the collection, an HTML::Object::IndexSizeError is returned.

See also Mozilla documentation

insertCell

Returns an HTML::Object::DOM::Element::TableCell representing a new cell of the table. It inserts it in the cells collection immediately before a td or th element at the given index position, if any was provided.

If the index is not given or is -1, the new cell is appended to the collection. If the index is smaller than -1, it will start that far back from the end of the collection array. If index is greater than the number of cells in the collection, an HTML::Object::IndexSizeError error is returned.

Example:

<table id="my-table">
    <tr><td>Row 1</td></tr>
    <tr><td>Row 2</td></tr>
    <tr><td>Row 3</td></tr>
</table>

sub addRow
{
    my $tableID = shift( @_ );
    # Get a reference to the table
    my $tableRef = $doc->getElementById( $tableID );

    # Insert a row at the end of the table
    my $newRow = $tableRef->insertRow( -1 );

    # Insert a cell in the row at index 0
    my $newCell = $newRow->insertCell( 0 );

    # Append a text node to the cell
    my $newText = $doc->createTextNode('New bottom row');
    $newCell->appendChild( $newText );
}

# Call addRow() with the table's ID
addRow( 'my-table' );

See also Mozilla documentation

DEPRECATED PROPERTIES

align

Is a string containing an enumerated value reflecting the align attribute. It indicates the alignment of the element's contents with respect to the surrounding context. The possible values are "left", "right", and "center".

See also Mozilla documentation

bgColor

Is a string containing the background color of the cells. It reflects the obsolete bgcolor attribute.

See also Mozilla documentation

bgcolor

Alias for "bgColor"

ch

Is a string containing one single character. This character is the one to align all the cell of a column on. It reflects the char and default to the decimal points associated with the language, e.g. '.' for English, or ',' for French. This property was optional and was not very well supported.

See also Mozilla documentation

chOff

Is a string containing a integer indicating how many characters must be left at the right (for left-to-right scripts; or at the left for right-to-left scripts) of the character defined by HTML::Object::DOM::Element::TableRow.ch. This property was optional and was not very well supported.

See also Mozilla documentation

choff

Alias for "chOff"

reset

When called, this will set a boolean value indicating the cached data must be recomputed. This allow the saving of computational power,

vAlign

Is a string representing an enumerated value indicating how the content of the cell must be vertically aligned. It reflects the valign attribute and can have one of the following values: "top", "middle", "bottom", or "baseline".

See also Mozilla documentation

valign

Alias for "vAlign"

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mozilla documentation, Mozilla documentation on tablerow element

COPYRIGHT & LICENSE

Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.