Provides advanced row selections.
This module provides an advanced way for selecting rows by clicking, swiping, SPACE key, or CTRL/SHIFT CLICK to select multiple rows. This module uses gridx/core/model/extensions/Mark.
Use select api on grid row object obtained from grid.row(i)
grid.row(1).select(); grid.row(1).deselect(); grid.row(1).isSelected();
Use select api on select.row module
grid.select.row.selectById(rowId); grid.select.row.deSelectById(rowId); grid.select.row.isSelected(rowId); grid.select.row.getSelected();//[] grid.select.row.clear();
If false, this module is disabled. This parameter is mainly used by DnD to not conflict with selection operations.
An array of module names. All these modules must exist, and have finished loading before this module loads. This property can be omitted.
If true, when selecting it'll appear as if the CTRL key is held.
If true, when selecting it'll appear as if the SHIFT key is held.
The API set name of this module. This name represents the API set that this module implements, instead of this module itself. Two different modules can have the same name, so that they provide two different implementations of this API set. For example, simple row selection and extended row selection are two modules implementing a same set of APIs. They can be used in two different grids in one page (maybe due to different requirements), without worrying about conflicting with eachother. And any module of grid can be replaced by a new implementation without re-writing any other modules. This property is mandatary.
An array of module names. These modules can be absent, but if they do exist, they must be loaded before this module loads. This property can be omitted.
An array of module names. These modules must exist, but they can be loaded at any time. This property can be omitted.
Whether to apply tri-state selection for child rows.
Whether row will be selected by clicking on cell, false by default
This method provides a normalized way to access module arguments.
There are two ways to provide module arguments when creating grid. One is to write them in the module declaration object:
var grid = new Grid({
......
modules: [
{
moduleClass: gridx.modules.Pagination,
initialPage: 1 //Put module arguments in module declaration object
}
],
......
});
This way is straightforward, but quite verbose. And if user would like to set arguments
for pre-included core modules (e.g. Header, Body), he'd have to explictly declare the module. This would be too demanding for a grid user, so we need another approach. The other way is to treat them as grid arguments:
var grid = new Grid({
......
modules: [
gridx.modules.Pagination
],
paginationInitialPage: 1, //Treat module arguments as grid arguments
......
});
In this way, there's no need to provide a module declaration object, but one has to tell
grid for which module the arguments is applied. One can simply put the module name at the front of every module argument: "pagination" -- module name
"initialPage" -- module argument
---------------------------------
paginationInitialPage -- module argument treated as grid argument
Note the first letter of the module arugment must be capitalized in the combined argument.
This "arg" method makes it possible to access module arguments without worring about where they are declared. The priority of every kinds of declarations are: Module argument > Grid argument > default value > Base class argument (inherited) After this method, the argument will automatically become module argument. But it is still recommended to alway access arguments by this.arg(...);
| Parameter | Type | Description |
|---|---|---|
| argName | String | The name of this argument. This is the "short" name, not the name prefixed with module name. |
| defaultValue | anything | Optional. This value will by asigned to the argument if there's no user provided values. |
| validate | Function | Optional. This is a validation function and it must return a boolean value. If the user provided value can not pass validation, the default value will be used. Note if this function is provided, defaultValue must also be provided. |
The value of this argument.
Do a lot of connects in a batch.
This method is used to optimize code size.
Connect an event handler to an event or function.
Similar to widget.connect, the scope of the listener will be default to this module. But in this API, the scope argument is placed behind the listener function, so as to avoid arguemnt checking logic. This method also allows conditional event firing using the flag argument.
| Parameter | Type | Description |
|---|---|---|
| obj | Object | |
| e | String | |
| method | String | Function | |
| scope | Object | Optional. |
| flag | Anything | If provided, the listener will only be triggered when grid._eventFlags[e] is set to flag. |
The connect handle
Deselect rows by id.
| Parameter | Type | Description |
|---|---|---|
| rowId | String... | Row ID |
Deselect a row by index. This function can also deselect multiple rows. Please refer to selectByIndex().
| Parameter | Type | Description |
|---|---|---|
| rowIndex | Integer... | Row visual indexes |
This function defines how to access this module's methods from the grid object.
The returned object of this function will be "recursively" mixed into the grid object. That is, any property of object type in grid will be preserved. For example, if this function returns { abc: { def: 'ghi'} }, and the grid already has a property called "abc", and grid.abc is { jkl: 'mno'}. Then after mixin, grid.abc will still have this jkl property:
{
abc: {
jkl: 'mno',
def: 'ghi'
}
}
This mechanism makes it possible for different modules to provide APIs to a same sub-API object.
Sub-API object is used to provide structures for grid APIs, so as to avoid API conflicts as much as possible. This function can be omitted.
Check if the given rows are all selected.
| Parameter | Type | Description |
|---|---|---|
| rowId | String | The ID of a row. |
True if all given columns are selected; false if not.
Completely load this module.
This is the formal loading process of this module. This function will not be called until all the "forced" and existing "optional" modules are loaded. When the loading process of this module is finished (Note that this might be an async process), this.loaded.callback() must be called to tell any other modules that depend on this module.
| Parameter | Type | Description |
|---|---|---|
| args | undefined | |
| deferStartup | undefined |
Preload this module.
If this function exists, it is called after all modules are created ("new"-ed), but not yet loaded. At this time point, all the module APIs are already accessable, so all the mothods of those modules that do not need to load can be used here. Note that this function is not the "load" process, so the module dependancy is not honored. For example, if module A forcedly depends on module B, it is still possible that module A.preload is called before module B.preload. This function can be omitted.
| Parameter | Type | Description |
|---|---|---|
| args | undefined |
Select rows by id.
| Parameter | Type | Description |
|---|---|---|
| rowId | String... | Row IDs |
Select a row by index This function can also select multiple rows.
//Select several individual rows:
gridx.select.row.selectByIndex(rowIndex1, rowIndex2, rowIndex3, ...);
//Select a range of rows:
gridx.select.row.selectByIndex([rowStartIndex, rowEndIndex]);
//Select multiple ranges of rows:
gridx.select.row.selectByIndex([rowStartIndex1, rowEndIndex1], [rowStartIndex2, rowEndIndex2], ...);| Parameter | Type | Description |
|---|---|---|
| rowIndex | Integer... | Row visual indexes |
Subscribe to a topic.
This is similar to widget.subscribe, except that the "scope" argument in this method is behind the listener function.
| Parameter | Type | Description |
|---|---|---|
| topic | undefined | |
| method | undefined | |
| scope | undefined |
The subscription handle
Fired when the selection is changed.
| Parameter | Type | Description |
|---|---|---|
| newSelectedIds | String[] | Current selected ids. |
| oldSelectedIds | String[] | Previous selected ids. |