Print Friendly

Class Ext.grid.RowSelectionModel

Package:Ext.grid
Class:RowSelectionModel
Extends:AbstractSelectionModel
Defined In:RowSelectionModel.js
The default SelectionModel used by Ext.grid.Grid. It supports multiple selections and keyboard selection/navigation.


Properties   -  Methods   -  Events   -  Config Options

Public Properties

This class has no public properties.

Public Methods

Method Defined By
  RowSelectionModelObject config ) RowSelectionModel
  addEventsObject object ) : void Observable
Used to define events on this Observable
  addListenerString eventName, Function handler, [Object scope], [Object options] ) : void Observable
Appends an event handler to this component
  clearSelections() : void RowSelectionModel
Clears all selections.
  deselectRangeNumber startRow, Number endRow ) : void RowSelectionModel
Deselects a range of rows. All rows in between startRow and endRow are also deselected.
  deselectRowNumber row ) : void RowSelectionModel
Deselects a row.
  fireEventString eventName, Object... args ) : Boolean Observable
Fires the specified event with the passed parameters (minus the event name).
  getCount() : Number RowSelectionModel
Gets the number of selected rows.
  getSelected() : Record RowSelectionModel
Returns the first selected record.
  getSelections() : Array RowSelectionModel
Returns the selected records
  hasListenerString eventName ) : Boolean Observable
Checks to see if this object has any listeners for a specified event
  hasSelection() : Boolean RowSelectionModel
Returns True if there is a selection.
  isIdSelectedString id ) : Boolean RowSelectionModel
Returns True if the specified record id is selected.
  isLocked() : Boolean AbstractSelectionModel
Returns true if the selections are locked.
  isSelectedNumber/Record record ) : Boolean RowSelectionModel
Returns True if the specified row is selected.
  lock() : void AbstractSelectionModel
Locks the selections.
  onString eventName, Function handler, [Object scope], [Object options] ) : void Observable
Appends an event handler to this element (shorthand for addListener)
  purgeListeners() : void Observable
Removes all listeners for this object
  removeListenerString eventName, Function handler, [Object scope] ) : void Observable
Removes a listener
  selectAll() : void RowSelectionModel
Selects all rows.
  selectFirstRow() : void RowSelectionModel
Selects the first row in the grid.
  selectLastRow[Boolean keepExisting] ) : void RowSelectionModel
Select the last row.
  selectNext[Boolean keepExisting] ) : void RowSelectionModel
Selects the row immediately following the last selected row.
  selectPrevious[Boolean keepExisting] ) : void RowSelectionModel
Selects the row that precedes the last selected row.
  selectRangeNumber startRow, Number endRow, [Boolean keepExisting] ) : void RowSelectionModel
Selects a range of rows. All rows in between startRow and endRow are also selected.
  selectRecordsArray records, [Boolean keepExisting] ) : void RowSelectionModel
Select records.
  selectRowNumber row, [Boolean keepExisting] ) : void RowSelectionModel
Selects a row.
  selectRowsArray rows, [Boolean keepExisting] ) : void RowSelectionModel
Selects multiple rows.
  unString eventName, Function handler, [Object scope] ) : void Observable
Removes a listener (shorthand for removeListener)
  unlock() : void AbstractSelectionModel
Unlocks the selections.

Public Events

Event Defined By
  beforerowselect : ( SelectionModel this, Number rowIndex, Boolean keepExisting ) RowSelectionModel
Fires when a row is selected being selected, return false to cancel.
  rowdeselect : ( SelectionModel this, Number rowIndex ) RowSelectionModel
Fires when a row is deselected.
  rowselect : ( SelectionModel this, Number rowIndex, @link Ext.data.Record} ) RowSelectionModel
Fires when a row is selected.
  selectionchange : ( SelectionModel this ) RowSelectionModel
Fires when the selection changes

Config Options

Config Options Defined By
  singleSelect : Boolean RowSelectionModel
True to allow selection of only one row at a time (defaults to false)

Constructor Details

RowSelectionModel

public function RowSelectionModel( Object config )
Parameters:
  • config : Object

Method Details

addEvents

public function addEvents( Object object )
Used to define events on this Observable
Parameters:
  • object : Object
    The object with the events defined
Returns:
  • void
This method is defined by Observable.

addListener

public function addListener( String eventName, Function handler, [Object scope], [Object options] )
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 in which to execute the handler function. The handler function's "this" context.
  • options : Object
    (optional) An object containing handler configuration properties. This may contain any of the following properties:
    • scope {Object} The scope in which to execute the handler function. The handler function's "this" context.
    • delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.
    • single {Boolean} True to add a handler to handle just the next firing of the event, and then remove itself.
    • buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

    Combining Options
    Using the options argument, it is possible to combine different types of listeners:

    A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)

    el.on('click', this.onClick, this, {
     			single: true,
        		delay: 100,
        		forumId: 4
    		});

    Attaching multiple handlers in 1 call
    The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.

    el.on({
    			'click': {
            		fn: this.onClick,
            		scope: this,
            		delay: 100
        		}, 
        		'mouseover': {
            		fn: this.onMouseOver,
            		scope: this
        		},
        		'mouseout': {
            		fn: this.onMouseOut,
            		scope: this
        		}
    		});

    Or a shorthand syntax which passes the same scope object to all handlers:

    el.on({
    			'click': this.onClick,
        		'mouseover': this.onMouseOver,
        		'mouseout': this.onMouseOut,
        		scope: this
    		});
Returns:
  • void
This method is defined by Observable.

clearSelections

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

deselectRange

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

deselectRow

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

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.

getCount

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

getSelected

public function getSelected()
Returns the first selected record.
Parameters:
  • None.
Returns:
  • Record
This method is defined by RowSelectionModel.

getSelections

public function getSelections()
Returns the selected records
Parameters:
  • None.
Returns:
  • Array
    Array of selected records
This method is defined by RowSelectionModel.

hasListener

public function hasListener( String eventName )
Checks to see if this object has any listeners for a specified event
Parameters:
  • eventName : String
    The name of the event to check for
Returns:
  • Boolean
    True if the event is being listened for, else false
This method is defined by Observable.

hasSelection

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

isIdSelected

public function isIdSelected( String id )
Returns True if the specified record id is selected.
Parameters:
  • id : String
    The id of record to check
Returns:
  • Boolean
This method is defined by RowSelectionModel.

isLocked

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

isSelected

public function isSelected( Number/Record record )
Returns True if the specified row is selected.
Parameters:
  • record : Number/Record
    The record or index of the record to check
Returns:
  • Boolean
This method is defined by RowSelectionModel.

lock

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

on

public function on( String eventName, Function handler, [Object scope], [Object options] )
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 in which to execute the handler function. The handler function's "this" context.
  • options : Object
    (optional)
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 RowSelectionModel.

selectFirstRow

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

selectLastRow

public function selectLastRow( [Boolean keepExisting] )
Select the last row.
Parameters:
  • keepExisting : Boolean
    (optional) True to keep existing selections
Returns:
  • void
This method is defined by RowSelectionModel.

selectNext

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

selectPrevious

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

selectRange

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

selectRecords

public function selectRecords( Array records, [Boolean keepExisting] )
Select records.
Parameters:
  • records : Array
    The records to select
  • keepExisting : Boolean
    (optional) True to keep existing selections
Returns:
  • void
This method is defined by RowSelectionModel.

selectRow

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

selectRows

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

un

public function un( String eventName, Function handler, [Object scope] )
Removes a listener (shorthand for removeListener)
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.

unlock

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

Event Details

beforerowselect

public event beforerowselect
Fires when a row is selected being selected, return false to cancel.
Subscribers will be called with the following parameters:
  • this : SelectionModel
  • rowIndex : Number
    The selected index
  • keepExisting : Boolean
    False if other selections will be cleared
This event is defined by RowSelectionModel.

rowdeselect

public event rowdeselect
Fires when a row is deselected.
Subscribers will be called with the following parameters:
  • this : SelectionModel
  • rowIndex : Number
    The selected index
This event is defined by RowSelectionModel.

rowselect

public event rowselect
Fires when a row is selected.
Subscribers will be called with the following parameters:
  • this : SelectionModel
  • rowIndex : Number
    The selected index
  • Ext.data.Record} : @link
    r The record
This event is defined by RowSelectionModel.

selectionchange

public event selectionchange
Fires when the selection changes
Subscribers will be called with the following parameters:
  • this : SelectionModel
This event is defined by RowSelectionModel.

Config Details

singleSelect

singleSelect : Boolean
True to allow selection of only one row at a time (defaults to false)
This config option is defined by RowSelectionModel.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.