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

dojox/grid/enhanced/_Plugin

Summary

This plugin provides functions to merge(un-merge) adjacent cells within one row. Acceptable plugin parameters:

{
    row: function(Integer)|Integer
        If it's a function, it's a predicate to decide which rows are to be merged.
        It takes an integer (the row index), and should return true or false;
    start: Integer
        The column index of the left most cell that shall be merged.
    end: Integer
        The column index of the right most cell that shall be merged.
    major: Integer
        The column index of the cell whose content should be used as the content of the merged cell.
        It must be larger than or equal to the startColumnIndex, and less than or equal to the endColumnIndex.
        If it is omitted, the content of the leading edge (left-most for ltr, right most for rtl) cell will be used.
}

Usage

var foo = new CellMerge(grid,args);
dojox/grid/enhanced/plugins/CellMerge
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

  • _createRecord(item)
  • _getWidth(colIndex)
  • _initEvents()
  • _isValid(item)
  • _mixinGrid()
  • _setupConfig(config)
  • _updateRows(item)
  • connect(obj,event,method) Connects specified obj/event to specified method of this object.
  • destroy() Destroy all resources.
  • disconnect(handle) Disconnects handle and removes it from connection list.
  • getMergedCells() Get all records of currently merged cells.
  • getMergedCellsByRow(rowIndex) Get the records of currently merged cells at the given row.
  • init()
  • mergeCells(rowTester,startColumnIndex,endColumnIndex,majorColumnIndex) Merge cells from startColumnIndex to endColumnIndex at rows that make rowTester return true, using the content of the cell at majorColumnIndex
  • subscribe(topic,method) Subscribes to the specified topic and calls the specified method of this object.
  • unmergeCells(mergeHandler) Unmerge the cells that are merged by the mergeHandler, which represents a call to the function mergeCells.
  • 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

_createRecord(item)
Parameter Type Description
item undefined
Returns:null
_getWidth(colIndex)
Parameter Type Description
colIndex undefined
Returns:undefined
_initEvents()
_isValid(item)
Parameter Type Description
item undefined
Returns:undefined
_mixinGrid()
_setupConfig(config)
Parameter Type Description
config undefined
_updateRows(item)
Parameter Type Description
item undefined
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
});
destroy()

Destroy all resources.

disconnect(handle)

Disconnects handle and removes it from connection list.

Parameter Type Description
handle undefined
getMergedCells()

Get all records of currently merged cells.

Returns:Array | undefined

An array of records for merged-cells. The record has the following structure:

{
    "row": 1, //the row index
    "start": 2, //the start column index
    "end": 4, //the end column index
    "major": 3, //the major column index
    "handle": someHandle, //The handler that covers this merge cell record.
}
getMergedCellsByRow(rowIndex)

Get the records of currently merged cells at the given row.

Parameter Type Description
rowIndex undefined
Returns:Array | object

An array of records for merged-cells. See docs of getMergedCells.

init()
mergeCells(rowTester,startColumnIndex,endColumnIndex,majorColumnIndex)

Merge cells from startColumnIndex to endColumnIndex at rows that make rowTester return true, using the content of the cell at majorColumnIndex

Parameter Type Description
rowTester undefined

If it's a function, it's a predicate to decide which rows are to be merged. It takes an integer (the row index), and should return true or false;

startColumnIndex Integer

The column index of the left most cell that shall be merged.

endColumnIndex Integer

The column index of the right most cell that shall be merged.

majorColumnIndex Integer
Optional

The column index of the cell whose content should be used as the content of the merged cell. It must be larger than or equal to the startColumnIndex, and less than or equal to the endColumnIndex. If it is omitted, the content of the leading edge (left-most for ltr, right most for rtl) cell will be used.

Returns:Object|null | undefined

A handler for the merged cells created by a call of this function. This handler can be used later to unmerge cells using the function unmergeCells If the merge is not valid, returns null;

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
});
unmergeCells(mergeHandler)

Unmerge the cells that are merged by the mergeHandler, which represents a call to the function mergeCells.

Parameter Type Description
mergeHandler object

A handler for the merged cells created by a call of function mergeCells.

unsubscribe(handle)

Un-subscribes handle and removes it from subscriptions list.

Parameter Type Description
handle undefined

Events

_onAfterRow(viewIdx,rowIndex,subrows)
Parameter Type Description
viewIdx undefined
rowIndex undefined
subrows 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(store)

Called when store is changed.

Parameter Type Description
store 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
});
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!