dojox/grid/enhanced/plugins/Selector (version 1.10)

dojox/grid/enhanced/_Plugin

Summary

Provides standard extended selection for grid. Supports mouse/keyboard selection, multi-selection, and de-selection.

Acceptable plugin parameters: The whole plugin parameter object is a config object passed to the setupConfig function.

Acceptable cell parameters defined in layout:

  1. notselectable: Boolean: Whether this column is (and all the cells in it are) selectable.

Usage

var foo = new Selector(grid,args);
dojox/grid/enhanced/plugins/Selector
Parameter Type Description
grid undefined
args undefined

Property Summary

  • _connectsList of all connections.
  • _subscribesList of all subscribes.
  • gridGrid that the plugin belongs to
  • nameplugin name
  • optionPlugin properties - leveraged with default and user specified properties. e.g. for dnd plugin, it may look like {"class": dojox.grid.enhanced.plugins.DnD, "dependency": ["nestedSorting"], ...}
  • privatesPrivate properties/methods shouldn't be mixin-ed anytime.

Method Summary

  • _add(type,items) Add to the selection record.
  • _addCellException(type,items) If some cells are deselected, maybe they have created "holes" in selected rows/cols.
  • _addException(type,items) If some rows/cols are deselected, maybe they have created "holes" in selected cols/rows.
  • _addToSelected(type) Record the selected items.
  • _blurPoint(type,point) Blur the current point.
  • _calcToHighlight(type,target,toHighlight,toSelect) Calculate what status should target have.
  • _clearSelection(type,reservedItem) Clear selection for given type and fire events, but retain the highlight for reservedItem, thus avoid "flashing".
  • _endSelect(type) End selection.
  • _fireEvent(evtName,type)
  • _focusPoint(type,point) Focus the current point, so when you move mouse, the focus indicator follows you.
  • _forEach(type,start,end,func,halfClose) Go through items from start point to end point.
  • _hacks() Complete the event system of grid, hack some grid functions to prevent default behavior.
  • _highlight(type,target,toSelect) Highlight from start point to target.
  • _highlightHeader(colIdx,toHighlight)
  • _highlightNode(node,toHighlight) Do the actual highlight work.
  • _highlightRowSelector(rowIdx,toHighlight)
  • _highlightSingle(type,toHighlight,target,toSelect,isRefresh) Highlight a single item.
  • _initAreas()
  • _initEvents() Connect events, create event handlers.
  • _isCellNotInExcept(type,item) Return true only when a cell is covered by selected row/col, and its not a "hole".
  • _isInLastRange(type,item,isSelected) Return true only when the item is in the last seletion/deseletion range.
  • _isSelected(type,item) Return true when the item is selected. (or logically selected, i.e, covered by a row/col).
  • _isValid(type,item,allowNotSelectable) Check whether the item is a valid __SelectItem for the given type.
  • _makeupForCells(type,newItems) When some rows/cols are selected, maybe they can cover some of the selected cells, and fill some of the "holes" in the selected cols/rows.
  • _makeupForExceptions(type,newCellItems) When new cells is selected, maybe they will fill in the "holes" in selected rows and columns.
  • _mixinGrid() Expose events to grid.
  • _refresh(type,toHighlight)
  • _refreshSelected()
  • _remove(type,items) Remove from the selection record.
  • _startSelect(type,start,extending,isRange,mandatarySelect,toSelect) Start selection, setup start point and current point, fire events.
  • clear(type) Clear all selections.
  • connect(obj,event,method) Connects specified obj/event to specified method of this object.
  • deselect(type,rowIndex,colIndex)
  • destroy()
  • disconnect(handle) Disconnects handle and removes it from connection list.
  • getLastSelectedRange(type) Get last selected range of the given type.
  • getSelected(type,includeExceptions) Get an array of selected locations.
  • getSelectedCount(type,includeExceptions) Get the number of selected items.
  • getSelectedType() Get the type of selected items.
  • init()
  • isSelected(type,rowIndex,colIndex) Check whether a location (a cell, a column or a row) is selected.
  • isSelecting(type) Check whether the user is currently selecting something.
  • select(type,rowIndex,colIndex) Select a location (a cell, a column or a row).
  • selectEnabled(toEnable) Turn on/off this selection functionality if toEnable is provided.
  • selectRange(type,start,end,toSelect) Select a continuous range (a block of cells, a set of continuous columns or rows)
  • setupConfig(config) Set selection mode for row/col/cell.
  • subscribe(topic,method) Subscribes to the specified topic and calls the specified method of this object.
  • toggleSelect(type,rowIndex,colIndex)
  • unsubscribe(handle) Un-subscribes handle and removes it from subscriptions list.

Event Summary

Properties

_connects

List of all connections.

_subscribes

List of all subscribes.

grid

Grid that the plugin belongs to

name

plugin name

option

Plugin properties - leveraged with default and user specified properties. e.g. for dnd plugin, it may look like {"class": dojox.grid.enhanced.plugins.DnD, "dependency": ["nestedSorting"], ...}

privates

Private properties/methods shouldn't be mixin-ed anytime.

Methods

_add(type,items)

Add to the selection record.

Parameter Type Description
type undefined
items undefined
_addCellException(type,items)

If some cells are deselected, maybe they have created "holes" in selected rows/cols.

Parameter Type Description
type undefined
items undefined
_addException(type,items)

If some rows/cols are deselected, maybe they have created "holes" in selected cols/rows.

Parameter Type Description
type undefined
items undefined
_addToSelected(type)

Record the selected items.

Parameter Type Description
type undefined
_blurPoint(type,point)

Blur the current point.

Parameter Type Description
type undefined
point undefined
_calcToHighlight(type,target,toHighlight,toSelect)

Calculate what status should target have. If toSelect is not provided, this is a no op.

Parameter Type Description
type undefined
target undefined
toHighlight undefined
toSelect undefined
Returns:boolean | undefined
_clearSelection(type,reservedItem)

Clear selection for given type and fire events, but retain the highlight for reservedItem, thus avoid "flashing".

Parameter Type Description
type String

"row", "col", or "cell

reservedItem Object

The item to retain highlight.

_endSelect(type)

End selection. Keep records, fire events and cleanup status.

Parameter Type Description
type String

"row", "col", or "cell"

_fireEvent(evtName,type)
Parameter Type Description
evtName undefined
type undefined
_focusPoint(type,point)

Focus the current point, so when you move mouse, the focus indicator follows you.

Parameter Type Description
type undefined
point undefined
_forEach(type,start,end,func,halfClose)

Go through items from start point to end point.

Parameter Type Description
type undefined
start undefined
end undefined
func undefined
halfClose undefined
_hacks()

Complete the event system of grid, hack some grid functions to prevent default behavior.

_highlight(type,target,toSelect)

Highlight from start point to target.

Parameter Type Description
type undefined
target undefined
toSelect Boolean

Whether we are selecting or deselecting.

_highlightHeader(colIdx,toHighlight)
Parameter Type Description
colIdx undefined
toHighlight undefined
_highlightNode(node,toHighlight)

Do the actual highlight work.

Parameter Type Description
node undefined
toHighlight undefined
_highlightRowSelector(rowIdx,toHighlight)
Parameter Type Description
rowIdx undefined
toHighlight undefined
_highlightSingle(type,toHighlight,target,toSelect,isRefresh)

Highlight a single item.

Parameter Type Description
type undefined
toHighlight undefined
target undefined
toSelect undefined
isRefresh undefined
_initAreas()
_initEvents()

Connect events, create event handlers.

_isCellNotInExcept(type,item)

Return true only when a cell is covered by selected row/col, and its not a "hole".

Parameter Type Description
type undefined
item undefined
Returns:undefined
_isInLastRange(type,item,isSelected)

Return true only when the item is in the last seletion/deseletion range.

Parameter Type Description
type undefined
item undefined
isSelected undefined
Returns:boolean | undefined
_isSelected(type,item)

Return true when the item is selected. (or logically selected, i.e, covered by a row/col).

Parameter Type Description
type undefined
item undefined
Returns:boolean | undefined
_isValid(type,item,allowNotSelectable)

Check whether the item is a valid __SelectItem for the given type.

Parameter Type Description
type undefined
item undefined
allowNotSelectable undefined
Returns:boolean
_makeupForCells(type,newItems)

When some rows/cols are selected, maybe they can cover some of the selected cells, and fill some of the "holes" in the selected cols/rows.

Parameter Type Description
type undefined
newItems undefined
_makeupForExceptions(type,newCellItems)

When new cells is selected, maybe they will fill in the "holes" in selected rows and columns.

Parameter Type Description
type undefined
newCellItems undefined
Returns:Array
_mixinGrid()

Expose events to grid.

_refresh(type,toHighlight)
Parameter Type Description
type undefined
toHighlight undefined
_refreshSelected()
_remove(type,items)

Remove from the selection record.

Parameter Type Description
type undefined
items undefined
_startSelect(type,start,extending,isRange,mandatarySelect,toSelect)

Start selection, setup start point and current point, fire events.

Parameter Type Description
type String

"row", "col", or "cell"

start Object

The start point

extending Boolean

Whether this is a multi selection

isRange Boolean

Whether this is a range selection (i.e. select from the last end point to this point)

mandatarySelect Boolean

If true, toSelect will be same as the original selection status.

toSelect undefined
clear(type)

Clear all selections.

Parameter Type Description
type String
Optional

"row" or "col" or "cell". If omitted, clear all.

connect(obj,event,method)

Connects specified obj/event to specified method of this object.

Parameter Type Description
obj undefined
event undefined
method undefined
Returns:undefined

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when foo.bar() is called, call the listener in the scope of plugin
plugin.connect(foo, "bar", function(){
    console.debug(this.xxx());//"this" - plugin scope
});
deselect(type,rowIndex,colIndex)
Parameter Type Description
type undefined
rowIndex undefined
colIndex undefined
destroy()
disconnect(handle)

Disconnects handle and removes it from connection list.

Parameter Type Description
handle undefined
getLastSelectedRange(type)

Get last selected range of the given type.

Parameter Type Description
type undefined
Returns:Object | null

{start: SelectItem, end: SelectItem} return null if nothing is selected.

getSelected(type,includeExceptions)

Get an array of selected locations.

Parameter Type Description
type String

"row" or "col" or "cell"

includeExceptions Boolean

Only meaningful for rows/columns. If true, all selected rows/cols, even they are partly selected, are all returned.

Returns:__SelectItem[] | undefined | Array
getSelectedCount(type,includeExceptions)

Get the number of selected items.

Parameter Type Description
type String

"row" or "col" or "cell"

includeExceptions Boolean

Only meaningful for rows/columns. If true, all selected rows/cols, even they are partly selected, are all returned.

Returns:Integer | undefined | number

The number of selected items.

getSelectedType()

Get the type of selected items.

Returns:String | undefined

"row" or "col" or "cell", or any mix of these (separator is | ).

init()
isSelected(type,rowIndex,colIndex)

Check whether a location (a cell, a column or a row) is selected.

Parameter Type Description
type String

"row" or "col" or "cell"

rowIndex Integer

If type is "row" or "cell", this is the row index. If type if "col", this is the column index.

colIndex Integer
Optional

Only valid when type is "cell"

Returns:Boolean | undefined

true if selected, false if not. If cell is covered by a selected column, it's selected.

isSelecting(type)

Check whether the user is currently selecting something.

Parameter Type Description
type String

"row" or "col" or "cell"

Returns:Boolean | undefined

true if is selection, false otherwise.

select(type,rowIndex,colIndex)

Select a location (a cell, a column or a row).

Parameter Type Description
type String

"row" or "col" or "cell"

rowIndex Integer

If type is "row" or "cell", this is the row index. If type if "col", this is the column index.

colIndex Integer
Optional

Only valid when type is "cell"

selectEnabled(toEnable)

Turn on/off this selection functionality if toEnable is provided. Check whether this selection functionality is enabled if nothing is passed in.

Parameter Type Description
toEnable Boolean
Optional

To enable or not.

Returns:Boolean|undefined | boolean

Enabled or not.

selectRange(type,start,end,toSelect)

Select a continuous range (a block of cells, a set of continuous columns or rows)

Parameter Type Description
type String

"row" or "col" or "cell"

start Integer | Object

If type is "row" or "col", this is the index of the starting row or column. If type if "cell", this is the left-top cell of the range.

end Integer | Object

If type is "row" or "col", this is the index of the ending row or column. If type if "cell", this is the right-bottom cell of the range.

toSelect undefined
setupConfig(config)

Set selection mode for row/col/cell.

Parameter Type Description
config Object

An object with the following structure (all properties are optional):

{
    //Default is "multi", all other values are same as "multi".
    row: false|"disabled"|"single",
    col: false|"disabled"|"single",
    cell: false|"disabled"|"single"
}
subscribe(topic,method)

Subscribes to the specified topic and calls the specified method of this object.

Parameter Type Description
topic undefined
method undefined
Returns:undefined

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
toggleSelect(type,rowIndex,colIndex)
Parameter Type Description
type undefined
rowIndex undefined
colIndex undefined
unsubscribe(handle)

Un-subscribes handle and removes it from subscriptions list.

Parameter Type Description
handle undefined

Events

_onExternalChange(type,target)
Parameter Type Description
type undefined
target undefined

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
_onInternalRearrange(type,mapping)
Parameter Type Description
type undefined
mapping undefined

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
_onSelectedById(id,newIndex,isSelected)
Parameter Type Description
id undefined
newIndex undefined
isSelected undefined

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
onPostInit()

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
onPreInit()

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
onSetStore()

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
onStartUp()

Examples

Example 1

var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
// when /my/topic is published, call the subscriber in the scope of plugin
// with passed parameter - "v"
plugin.subscribe("/my/topic", function(v){
    console.debug(this.xxx(v));//"this" - plugin scope
});
Error in the documentation? Can’t find what you are looking for? Let us know!