gridx
Legend: Array Boolean Constructor Date DomNode Error Function Namespace Number Object RegExp Singleton String

gridx.core._Module

Object » gridx.core._Module
dojo.require("gridx.core._Module");
Defined in gridx/core/_Module.js

Method Summary

  • arg(argName, defaultValue, validate) returns anything This method provides a normalized way to access module arguments.
  • aspect(obj, e, method, scope, pos)
  • batchConnect() Do a lot of connects in a batch.
  • connect(obj, e, method, scope, flag) returns Object Connect an event handler to an event or function.
  • constructor(grid, args)
  • destroy()
  • getAPIPath() This function defines how to access this module's methods from the grid object.
  • load(args, deferStartup) Completely load this module.
  • preload(args) Preload this module.
  • subscribe(topic, method, scope) returns Object Subscribe to a topic.

Methods

arg
Returns anything: The value of this argument.

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(...);

ParameterTypeDescription
argNameStringThe name of this argument. This is the "short" name, not the name prefixed with module name.
defaultValueanything
Optional.
This value will by asigned to the argument if there's no user provided values.
validateFunction
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.
aspect
ParameterTypeDescription
obj
e
method
scope
pos
batchConnect

This method is used to optimize code size.

connect
Returns Object: The connect handle

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.

ParameterTypeDescription
objObject
eString
methodString|Function
scopeObject
Optional.
flagAnythingIf provided, the listener will only be triggered when grid._eventFlags[e] is set to flag.
constructor
ParameterTypeDescription
grid
args
destroy
getAPIPath

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.

load

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.

ParameterTypeDescription
args
deferStartup
preload

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.

ParameterTypeDescription
args
subscribe
Returns Object: The subscription handle

This is similar to widget.subscribe, except that the "scope" argument in this method is behind the listener function.

ParameterTypeDescription
topic
method
scope