public/javascripts/yui/datatable/datatable.js
function(e) {
    var nKey = Ev.getCharCode(e);

    if((nKey == 38) || (nKey == 40)) {
        // Validate trigger
        var oTrigger = this._getSelectionTrigger();
        // Arrow selection only works if last selected row is on current page
        if(!oTrigger) {
            return null;
        }

        Ev.stopEvent(e);

        // Determine the new row to select
        var elNew;
        if(nKey == 38) { // arrow up
            elNew = this.getPreviousTrEl(oTrigger.el);

            // Validate new row
            if(elNew === null) {
                //TODO: wrap around to last tr on current page
                //elNew = this.getLastTrEl();

                //TODO: wrap back to last tr of previous page

                // Top row selection is sticky
                elNew = this.getFirstTrEl();
            }
        }
        else if(nKey == 40) { // arrow down
            elNew = this.getNextTrEl(oTrigger.el);

            // Validate new row
            if(elNew === null) {
                //TODO: wrap around to first tr on current page
                //elNew = this.getFirstTrEl();

                //TODO: wrap forward to first tr of previous page

                // Bottom row selection is sticky
                elNew = this.getLastTrEl();
            }
        }

        // Unselect all rows
        this.unselectAllRows();

        // Select the new row
        this.selectRow(elNew);

        // Set new anchor
        this._oAnchorRecord = this.getRecord(elNew);
    }
}
function(e) {
    var nKey = Ev.getCharCode(e);

    if((nKey == 38) || (nKey == 40)) {
        // Validate trigger
        var oTrigger = this._getSelectionTrigger();
        // Arrow selection only works if last selected row is on current page
        if(!oTrigger) {
            return null;
        }

        Ev.stopEvent(e);

        // Determine the new row to select
        var elNew;
        if(nKey == 38) { // arrow up
            elNew = this.getPreviousTrEl(oTrigger.el);

            // Validate new row
            if(elNew === null) {
                //TODO: wrap around to last tr on current page
                //elNew = this.getLastTrEl();

                //TODO: wrap back to last tr of previous page

                // Top row selection is sticky
                elNew = this.getFirstTrEl();
            }
        }
        else if(nKey == 40) { // arrow down
            elNew = this.getNextTrEl(oTrigger.el);

            // Validate new row
            if(elNew === null) {
                //TODO: wrap around to first tr on current page
                //elNew = this.getFirstTrEl();

                //TODO: wrap forward to first tr of previous page

                // Bottom row selection is sticky
                elNew = this.getLastTrEl();
            }
        }

        // Unselect all rows
        this.unselectAllRows();

        // Select the new row
        this.selectRow(elNew);

        // Set new anchor
        this._oAnchorRecord = this.getRecord(elNew);
    }
}
function ( e ) { var nKey = Ev . getCharCode ( e ) ; if ( ( nKey == 38 ) || ( nKey == 40 ) ) { // Validate trigger var oTrigger = this . _getSelectionTrigger ( ) ; // Arrow selection only works if last selected row is on current page if ( ! oTrigger ) { return null ; } Ev . stopEvent ( e ) ; // Determine the new row to select var elNew ; if ( nKey == 38 ) { // arrow up elNew = this . getPreviousTrEl ( oTrigger . el ) ; // Validate new row if ( elNew === null ) { //TODO: wrap around to last tr on current page //elNew = this.getLastTrEl(); //TODO: wrap back to last tr of previous page // Top row selection is sticky elNew = this . getFirstTrEl ( ) ; } } else if ( nKey == 40 ) { // arrow down elNew = this . getNextTrEl ( oTrigger . el ) ; // Validate new row if ( elNew === null ) { //TODO: wrap around to first tr on current page //elNew = this.getFirstTrEl(); //TODO: wrap forward to first tr of previous page // Bottom row selection is sticky elNew = this . getLastTrEl ( ) ; } } // Unselect all rows this . unselectAllRows ( ) ; // Select the new row this . selectRow ( elNew ) ; // Set new anchor this . _oAnchorRecord = this . getRecord ( elNew ) ; } }
Determines selection behavior resulting from a key event when selection mode
is set to "single".

@method _handleSingleSelectionByKey
@param e {HTMLEvent} Event object.
@private
Determines selection behavior resulting from a key event when selection mode is set to single .