public/javascripts/yui/datatable/datatable.js
function(row) {
    var nRecordIndex;

    // By Record
    if(row instanceof YAHOO.widget.Record) {
        nRecordIndex = this._oRecordSet.getRecordIndex(row);
        if(nRecordIndex === null) {
            // Not a valid Record
            return null;
        }
    }
    // Calculate page row index from Record index
    else if(lang.isNumber(row)) {
        nRecordIndex = row;
    }
    if(lang.isNumber(nRecordIndex)) {
        // Validate the number
        if((nRecordIndex > -1) && (nRecordIndex < this._oRecordSet.getLength())) {
            // DataTable is paginated
            var oPaginator = this.get('paginator');
            if(oPaginator) {
                // Check the record index is within the indices of the
                // current page
                var rng = oPaginator.getPageRecords();
                if (rng && nRecordIndex >= rng[0] && nRecordIndex <= rng[1]) {
                    // This Record is on current page
                    return nRecordIndex - rng[0];
                }
                // This Record is not on current page
                else {
                    return null;
                }
            }
            // Not paginated, just return the Record index
            else {
                return nRecordIndex;
            }
        }
        // RecordSet index is out of range
        else {
            return null;
        }
    }
    // By element reference or ID string
    else {
        // Validate TR element
        var elRow = this.getTrEl(row);
        if(elRow && (elRow.ownerDocument == document) &&
                (elRow.parentNode == this._elTbody)) {
            return elRow.sectionRowIndex;
        }
    }

    return null;
}
function(row) {
    var nRecordIndex;

    // By Record
    if(row instanceof YAHOO.widget.Record) {
        nRecordIndex = this._oRecordSet.getRecordIndex(row);
        if(nRecordIndex === null) {
            // Not a valid Record
            return null;
        }
    }
    // Calculate page row index from Record index
    else if(lang.isNumber(row)) {
        nRecordIndex = row;
    }
    if(lang.isNumber(nRecordIndex)) {
        // Validate the number
        if((nRecordIndex > -1) && (nRecordIndex < this._oRecordSet.getLength())) {
            // DataTable is paginated
            var oPaginator = this.get('paginator');
            if(oPaginator) {
                // Check the record index is within the indices of the
                // current page
                var rng = oPaginator.getPageRecords();
                if (rng && nRecordIndex >= rng[0] && nRecordIndex <= rng[1]) {
                    // This Record is on current page
                    return nRecordIndex - rng[0];
                }
                // This Record is not on current page
                else {
                    return null;
                }
            }
            // Not paginated, just return the Record index
            else {
                return nRecordIndex;
            }
        }
        // RecordSet index is out of range
        else {
            return null;
        }
    }
    // By element reference or ID string
    else {
        // Validate TR element
        var elRow = this.getTrEl(row);
        if(elRow && (elRow.ownerDocument == document) &&
                (elRow.parentNode == this._elTbody)) {
            return elRow.sectionRowIndex;
        }
    }

    return null;
}
function ( row ) { var nRecordIndex ; // By Record if ( row instanceof YAHOO . widget . Record ) { nRecordIndex = this . _oRecordSet . getRecordIndex ( row ) ; if ( nRecordIndex === null ) { // Not a valid Record return null ; } } // Calculate page row index from Record index else if ( lang . isNumber ( row ) ) { nRecordIndex = row ; } if ( lang . isNumber ( nRecordIndex ) ) { // Validate the number if ( ( nRecordIndex > - 1 ) && ( nRecordIndex < this . _oRecordSet . getLength ( ) ) ) { // DataTable is paginated var oPaginator = this . get ( 'paginator' ) ; if ( oPaginator ) { // Check the record index is within the indices of the // current page var rng = oPaginator . getPageRecords ( ) ; if ( rng && nRecordIndex >= rng [ 0 ] && nRecordIndex <= rng [ 1 ] ) { // This Record is on current page return nRecordIndex - rng [ 0 ] ; } // This Record is not on current page else { return null ; } } // Not paginated, just return the Record index else { return nRecordIndex ; } } // RecordSet index is out of range else { return null ; } } // By element reference or ID string else { // Validate TR element var elRow = this . getTrEl ( row ) ; if ( elRow && ( elRow . ownerDocument == document ) && ( elRow . parentNode == this . _elTbody ) ) { return elRow . sectionRowIndex ; } } return null ; }
Returns the page row index of given row. Returns null if the row is not on the
current DataTable page.

@method getTrIndex
@param row {HTMLElement | String | YAHOO.widget.Record | Number} DOM or ID
string reference to an element within the DataTable page, a Record instance,
or a Record's RecordSet index.
@return {Number} Page row index, or null if row does not exist or is not on current page.
Returns the page row index of given row . Returns null if the row is not on the current DataTable page .