Print Friendly

Class YAHOO.ext.grid.DefaultSelectionModel

Package:YAHOO.ext.grid
Class:DefaultSelectionModel
Extends:Observable
Subclasses:EditorSelectionModel, SingleSelectionModel
Defined In:SelectionModel.js
The default SelectionModel used by YAHOO.ext.grid.Grid. It supports multiple selections and keyboard selection/navigation.


Public Properties

This class has no public properties.

Public Methods

Method Defined By
  DefaultSelectionModel() DefaultSelectionModel
  addListener(String eventName, Function handler, [Object scope], [boolean override]) : void Observable
Appends an event handler to this component
  bufferedListener(String eventName, Function handler, [Object scope], [Number millis]) : Function Observable
Appends an event handler to this component that is buffered. If the event is triggered more than once in the specifie...
  clearSelections() : void DefaultSelectionModel
Clears all selections.
  delayedListener(String eventName, Function handler, [Object scope], [Number delay]) : Function Observable
Appends an event handler to this component that is delayed the specified number of milliseconds. This is useful for e...
  deselectRange(Number/HTMLElement startRow, Number/HTMLElement endRow) : void DefaultSelectionModel
Deselects a range of rows. All rows in between startRow and endRow are also deselected.
  deselectRow(Number/HTMLElement row) : void DefaultSelectionModel
Deselects a row.
  fireEvent(String eventName, Object... args) : Boolean Observable
Fires the specified event with the passed parameters (minus the event name).
  focusRow(HTMLElement row) : void DefaultSelectionModel
Deprecated. Deprecated. Tries to focus the row and scroll it into view - Use grid.scrollTo or grid.getView().focusRow...
  getCount() : Number DefaultSelectionModel
Gets the number of selected rows.
  getSelectedRowIds() : Array DefaultSelectionModel
Returns the selected row ids.
  getSelectedRows() : Array DefaultSelectionModel
Returns the selected rows.
  hasSelection() : Boolean DefaultSelectionModel
Returns True if there is a selection.
  isLocked() : Boolean DefaultSelectionModel
Returns true if the selections are locked
  isSelectable(HTMLElement row) : Boolean DefaultSelectionModel
Returns True if the specified row is selectable.
  isSelected(HTMLElement row) : Boolean DefaultSelectionModel
Returns True if the specified row is selected.
  lock() : void DefaultSelectionModel
Lock the selections
  on(String eventName, Function handler, [Object scope], [boolean override]) : void Observable
Appends an event handler to this element (shorthand for addListener)
  purgeListeners() : void Observable
Removes all listeners for this object
  removeListener(String eventName, Function handler, [Object scope]) : void Observable
Removes a listener
  selectAll() : void DefaultSelectionModel
Selects all rows.
  selectFirstRow() : void DefaultSelectionModel
Selects the first row in the grid.
  selectNext([Boolean keepExisting]) : void DefaultSelectionModel
Selects the row immediately following the last selected row.
  selectPrevious([Boolean keepExisting]) : void DefaultSelectionModel
Selects the row that precedes the last selected row.
  selectRange(Number/HTMLElement startRow, Number/HTMLElement endRow, [Boolean keepExisting]) : void DefaultSelectionModel
Selects a range of rows. All rows in between startRow and endRow are also selected.
  selectRow(Number/HTMLElement row, [Boolean keepExisting]) : void DefaultSelectionModel
Selects a row.
  selectRows(Array rows, [Boolean keepExisting]) : void DefaultSelectionModel
Selects multiple rows.
  selectRowsById(String/Array id, [Boolean keepExisting]) : void DefaultSelectionModel
Set the selected rows by their ID(s). IDs must match what is returned by the DataModel getRowId(index).
  unlock() : void DefaultSelectionModel
Unlock the selections

Public Events

Event Defined By
  rowselect : (SelectionModel this, HTMLElement row, Boolean selected) DefaultSelectionModel
Fires when a row is selected or deselected
  selectionchange : (SelectionModel this, Array rows, String ids) DefaultSelectionModel
Fires when the selection changes

Constructor Details

DefaultSelectionModel

public function DefaultSelectionModel()
Parameters:
  • None.

Method Details

addListener

public function addListener(String eventName, Function handler, [Object scope], [boolean override])
Appends an event handler to this component
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • override : boolean
    (optional) If true, scope becomes the scope
Returns:
  • void
This method is defined by Observable.

bufferedListener

public function bufferedListener(String eventName, Function handler, [Object scope], [Number millis])
Appends an event handler to this component that is buffered. If the event is triggered more than once in the specified time-frame, only the last one actually fires.
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • millis : Number
    (optional) The number of milliseconds to buffer (defaults to 250)
Returns:
  • Function
    The wrapped function that was created (can be used to remove the listener)
This method is defined by Observable.

clearSelections

public function clearSelections()
Clears all selections.
Parameters:
  • None.
Returns:
  • void
This method is defined by DefaultSelectionModel.

delayedListener

public function delayedListener(String eventName, Function handler, [Object scope], [Number delay])
Appends an event handler to this component that is delayed the specified number of milliseconds. This is useful for events that modify the DOM and need to wait for the browser to catch up.
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • delay : Number
    (optional) The number of milliseconds to delay (defaults to 1 millisecond)
Returns:
  • Function
    The wrapped function that was created (can be used to remove the listener)
This method is defined by Observable.

deselectRange

public function deselectRange(Number/HTMLElement startRow, Number/HTMLElement endRow)
Deselects a range of rows. All rows in between startRow and endRow are also deselected.
Parameters:
  • startRow : Number/HTMLElement
    The row or index of the first row in the range
  • endRow : Number/HTMLElement
    The row or index of the last row in the range
Returns:
  • void
This method is defined by DefaultSelectionModel.

deselectRow

public function deselectRow(Number/HTMLElement row)
Deselects a row.
Parameters:
  • row : Number/HTMLElement
    The row or index of the row to deselect
Returns:
  • void
This method is defined by DefaultSelectionModel.

fireEvent

public function fireEvent(String eventName, Object... args)
Fires the specified event with the passed parameters (minus the event name).
Parameters:
  • eventName : String
  • args : Object...
    Variable number of parameters are passed to handlers
Returns:
  • Boolean
    returns false if any of the handlers return false otherwise it returns true
This method is defined by Observable.

focusRow

public function focusRow(HTMLElement row)
Deprecated. Deprecated. Tries to focus the row and scroll it into view - Use grid.scrollTo or grid.getView().focusRow() instead.
Parameters:
  • row : HTMLElement
    The row to focus
Returns:
  • void
This method is defined by DefaultSelectionModel.

getCount

public function getCount()
Gets the number of selected rows.
Parameters:
  • None.
Returns:
  • Number
This method is defined by DefaultSelectionModel.

getSelectedRowIds

public function getSelectedRowIds()
Returns the selected row ids.
Parameters:
  • None.
Returns:
  • Array
    Array of String ids
This method is defined by DefaultSelectionModel.

getSelectedRows

public function getSelectedRows()
Returns the selected rows.
Parameters:
  • None.
Returns:
  • Array
    Array of DOM row elements
This method is defined by DefaultSelectionModel.

hasSelection

public function hasSelection()
Returns True if there is a selection.
Parameters:
  • None.
Returns:
  • Boolean
This method is defined by DefaultSelectionModel.

isLocked

public function isLocked()
Returns true if the selections are locked
Parameters:
  • None.
Returns:
  • Boolean
This method is defined by DefaultSelectionModel.

isSelectable

public function isSelectable(HTMLElement row)
Returns True if the specified row is selectable.
Parameters:
  • row : HTMLElement
    The row to check
Returns:
  • Boolean
This method is defined by DefaultSelectionModel.

isSelected

public function isSelected(HTMLElement row)
Returns True if the specified row is selected.
Parameters:
  • row : HTMLElement
    The row to check
Returns:
  • Boolean
This method is defined by DefaultSelectionModel.

lock

public function lock()
Lock the selections
Parameters:
  • None.
Returns:
  • void
This method is defined by DefaultSelectionModel.

on

public function on(String eventName, Function handler, [Object scope], [boolean override])
Appends an event handler to this element (shorthand for addListener)
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • override : boolean
    (optional) If true, scope becomes the scope
Returns:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
Removes all listeners for this object
Parameters:
  • None.
Returns:
  • void
This method is defined by Observable.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
Removes a listener
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The handler to remove
  • scope : Object
    (optional) The scope (this object) for the handler
Returns:
  • void
This method is defined by Observable.

selectAll

public function selectAll()
Selects all rows.
Parameters:
  • None.
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectFirstRow

public function selectFirstRow()
Selects the first row in the grid.
Parameters:
  • None.
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectNext

public function selectNext([Boolean keepExisting])
Selects the row immediately following the last selected row.
Parameters:
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectPrevious

public function selectPrevious([Boolean keepExisting])
Selects the row that precedes the last selected row.
Parameters:
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectRange

public function selectRange(Number/HTMLElement startRow, Number/HTMLElement endRow, [Boolean keepExisting])
Selects a range of rows. All rows in between startRow and endRow are also selected.
Parameters:
  • startRow : Number/HTMLElement
    The row or index of the first row in the range
  • endRow : Number/HTMLElement
    The row or index of the last row in the range
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectRow

public function selectRow(Number/HTMLElement row, [Boolean keepExisting])
Selects a row.
Parameters:
  • row : Number/HTMLElement
    The row or index of the row to select
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectRows

public function selectRows(Array rows, [Boolean keepExisting])
Selects multiple rows.
Parameters:
  • rows : Array
    Array of the rows or indexes of the row to select
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

selectRowsById

public function selectRowsById(String/Array id, [Boolean keepExisting])
Set the selected rows by their ID(s). IDs must match what is returned by the DataModel getRowId(index).
Parameters:
  • id : String/Array
    The id(s) to select
  • keepExisting : Boolean
    (optional) True to retain existing selections
Returns:
  • void
This method is defined by DefaultSelectionModel.

unlock

public function unlock()
Unlock the selections
Parameters:
  • None.
Returns:
  • void
This method is defined by DefaultSelectionModel.

Event Details

rowselect

public event rowselect
Fires when a row is selected or deselected
Subscribers will be called with the following parameters:
  • this : SelectionModel
  • row : HTMLElement
    The row element
  • selected : Boolean
    true if the row was selected, false if deselected
This event is defined by DefaultSelectionModel.

selectionchange

public event selectionchange
Fires when the selection changes
Subscribers will be called with the following parameters:
  • this : SelectionModel
  • rows : Array
    Array of row elements that are selected
  • ids : String
    Array of ids that are selected
This event is defined by DefaultSelectionModel.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.