Members
-
<constant> extendDataColumnAttribute
-
Normalize the attributes configuration
Methods
-
cellsProjectionHandler(state)
-
Fill the headRows, bodyRows and footRows with cells.
Parameters:
Name Type Description stateContentChainState All data, configurations and events needed in grid cells.
Returns:
- Type
- ContentChainState
-
columnGroupProjectionHandler(state)
-
Resolve grid structure from columns configuration and build the ColumnGroup object.
Parameters:
Name Type Description stateContentChainState The input content chain state.
Returns:
- Type
- ContentChainState
-
columnsProjectionHandler(state [, columnsConfig])
-
Columns projection handling columns configuration
- If the columnsConfig is null, generate the columns config.
- Add head/body/foot attribute data-column="name" which will render data-column attribute on each cell.
Parameters:
Name Type Argument Description stateObject Properties
Name Type Argument Description itemsArray.<object> | FakeArray <optional>
Original data items from data source.
columnsConfigArray.<ColumnConfig> <optional>
Columns configuration defined by user. If omitted, all columns in original data will be shown.
-
eventsProjectionHandler(state, eventsOptions)
-
Merge the customized events with the projection injected events.
Parameters:
Name Type Description stateContentChainState The input state.
eventsOptionsexternal:BackboneViewEventHash The customized events in form of
Backbone.View#events. -
normalizeAttributes(attributes, context)
-
Normalize the attributes configuration
Parameters:
Name Type Description attributesAttributesConfig The attributes configuration.
contextObject The context for the classes. It could be
- A ColumnConfig for a column's headAttributes/colAttributes
- A RowConfig for a column or row's bodyAttributes/footAttributes
- An object representing the data item for data rows in the body
Returns:
The normalized attributes configuration.
- Type
- Object.<string, string>
-
normalizeClasses(classes, context)
-
Normalize the classes configuration
Parameters:
Name Type Description classesClassesConfig The classes configuration.
contextObject The context for the classes. It could be
- A ColumnConfig for a column's headClasses/colClasses
- A RowConfig for a column or row's bodyClasses/footClasses
- An object representing the data item for data rows in the body
Returns:
The normalized classes configuration.
- Type
- Array.<string>
-
normalizeSelectionConfig(selection)
-
Normalize the selection config
Parameters:
Name Type Description selectionboolean | SelectionConfig The selection configuration.
-
queryProjectionHandler(state, params)
-
Fetching data from the data source
Parameters:
Name Type Description stateDataChainState paramsQueryConfig The data source configurations.
Returns:
- Type
- DataChainState
-
rowsProjectionHandler(state, options)
-
Handling bodyRows and adding headRows, bodyRows, footRows to state
Parameters:
Name Type Description stateStructureChainState The input state.
optionsRowsConfig The configuration for rows projection.
Returns:
- Type
- StructureChainState
-
selectionProjectionHandler(state, selection)
-
Add selection box to rows
Parameters:
Name Type Description stateStructureChainState The input state.
selectionboolean | SelectionConfig The selection configuration. It can be
- A boolean to indicate whether the grid has the selection column.
- A detailed SelectionConfig object.
-
sortableHeaderProjectionHandler(state, options)
-
Add click event to sortable column and wrap sortable column's head with a template
Parameters:
Name Type Description stateContentChainState The input state.
optionsSortableHeaderConfig The sortable header configurations.
-
translateRow(options, rowType, primaryKey)
-
Translate the RowConfig into RowContent
Parameters:
Name Type Description optionsObject Properties
Name Type Description columnGroupColumnGroup The column group.
rowRowConfig The RowConfig to translate.
rowTypestring Which group the row belongs to. It could be 'head', 'body' or 'foot'.
primaryKeystring The primary key of the data items.
Returns:
- Type
- RowContent
Type Definitions
-
BuiltinDataSourceConfig
-
Type:
- Object
Properties:
Name Type Argument Description typestring The builtin data source type, available values are 'odata', 'js-data' and 'memory'.
primaryKeystring <nullable>
The primaryKey for the data source. Required by 'odata' and 'memory' data sources.
entityJSDataResource <nullable>
The JSDataResource representing the entity set. Required by 'js-data' data source.
urlstring <nullable>
The URL for the entity set. Required by 'odata' data source.
dataArray.<Object> <nullable>
The in-memory data set. Required by 'memory' data source.
-
CellContent
-
The object represents a cell.
Type:
- Object
Properties:
Name Type Description classesArray.<string> The classes for the
TD/THelementattributesObject.<string, string> The HTML attributes for the
TD/THelement.htmlstring The HTML string to be rendered inside the cell.
viewBackbone.View The Backbone View to be filled into the cell. Unsupported for the body cells.
groupstring [group=other] Group name. A Row will be separated by the group name. [[cell, cell], [cell], [cell]]
-
ClassesConfig
-
The classes configuration. It could be
- A array of class strings
- A space separated classes string
- A hash from class names to ClassPredicate
Type:
- Array.<string> | string | Object.<string, ClassPredicate>
-
ClassPredicate
-
A boolean or a callback to decide whether or not a class is applied. When it's a function, it takes the context and return a boolean.
Type:
- boolean | ClassPredicateCallback
-
ClassPredicateCallback(context)
-
Parameters:
Name Type Description contextObject Refer to the
contextof normalizeClasses.Returns:
Whether or not the class is applied.
- Type
- boolean
-
ColContent
-
The content of a
COLelement inCOLGROUP.Type:
- Object
Properties:
Name Type Description classesArray.<string> The classes of the
COLelement.widthnumber | string The CSS width for the column.
-
ColumnConfig
-
Type:
- Object
- A key path string. E.g. 'Foo/Bar'.
- A PropertyCallback function
- A PropertyConfig object
- A boolean simply say the column is sortable or not.
- A number, positive for ascending first, otherwise descending first.
- A string, the key path of the sorting values.
- A PropertyGetter to get the sorting values from data items. Only available for memory data source.
- A detailed SortableConfig object.
Properties:
Name Type Description namestring Name of the column.
titlestring The localized column title. The
namewill be used iftitleis omitted.htmlstring The HTML string to be rendered in the column header. The
titlestring will be rendered in the column header ifhtmlis omitted.propertystring | PropertyCallback | PropertyConfig The data property of the column. It defines how to get/set values with a data item. If it's omitted, will use the column
nameas the key path. It could betemplateCellTemplate The template to render a cell for the column.
sortableboolean | number | OrderByKey The ordering configuration. If it's omitted, the column is unsortable. It could be
colClassesClassesConfig The classes for the
COLelement inCOLGROUP.headClassesClassesConfig The classes for the
THelement inTHEAD.bodyClassesClassesConfig The classes for the
TDelements inTBODY.footClassesClassesConfig The classes for the
TDelements inTFOOT.colAttributesClassesConfig The attributes for the
COLelement inCOLGROUP.headAttributesAttributesConfig The attributes for the
THelements inTHEAD.bodyAttributesAttributesConfig The attributes for the
TDelements inTBODY.footAttributesAttributesConfig The attributes for the
TDelements inTFOOT.columnsArray.<ColumnConfig> The children columns.
-
ContentChainState
-
It extends the StructureChainState with extra properties, and overrides some of the properties.
Type:
Properties:
Name Type Description columnGroupColumnGroup The column group object, represents the compiled column hierarchy.
colsArray.<ColContent> The content for
COLelements inCOLGROUP.headRowsRowContent The content for rows in
THEAD.bodyRowsRowContent The content for rows in
TBODY.footRowsRowContent The content for rows in
TFOOT. -
DataChainState
-
Type:
- Object
Properties:
Name Type Description uniqueIdstring The unique id for the set of data items. It changes each time new query is made to the server.
primaryKeystring The primary key of the data items.
itemsArray.<Object> | FakeArray An array or a fake array of data items.
totalCountnumber The total item count on the server.
itemIndexObject.<string, Object> The items indexed by primary key.
eventsexternal:BackboneViewEventHash The event has in form of
Backbone.View#events. Any projection can response to the DOM events by adding its own event handlers. -
DataSourceConfig
-
Type:
-
ExtendedColumnConfig
-
An extended internal representation of columns. It extends ColumnConfig with several extra properties.
Type:
Properties:
Name Type Description parentExtendedColumnConfig The parent column if there's a column hierarchy.
columnsArray.<ExtendedColumnConfig> The children columns.
cellCellContent The configuration of the header cell.
heightnumber The rowspan of the header cell.
treeWidthnumber The colspan of the header cell. The tree width of the column subtree in number of columns.
treeHeightnumber The height of the column subtree in number of rows.
-
FakeArray
-
A object implements a minimal interface of array to lazy fetch items. We use this structure a lot in projections, so that we don't need to procceed all the rows when virtualization is on.
Type:
- Object
Properties:
Name Type Description slicefunction a callback to get a slice of the items. It has the same signature as
Array.slice().lengthnumber length of the array
-
GridViewConfig
-
Type:
- Object
- The DOM events inside the
GridView. - The
GridViewevents, e.g. GridView#willUpdate, GridView#didUpdate.
Properties:
Name Type Description namestring Name of the grid
elstring | HTMLElement | jQuery The root element of the grid view.
scrollingScrollingConfig The scrolling behavior configuratoin.
tableClassesArray.<strings> An array of classes to be applied to
TABLEelements.tableAttributesobject An object of attributes to be applied to
TABLEelements.pluginsObject.<string, Object> The plugin configurations. The keys are the plugin names, and the values are the configuation objects.
rowsRowsConfig The structure of the head/body/foot rows.
columnsArray.<ColumnConfig> Array of the columns configurations.
dataSourceDataSourceConfig The data source configurations. Tells the grid how to fetch data.
queryQueryConfig The query parameters for data fetch.
selectionSelectionConfig Config the behavior for row selection.
sortableHeaderSortableHeaderConfig Config the state and visual of the click-to-sort column headers.
eventsexternal:BackboneViewEventHash Customized event hash in form of
Backbone.View#events. It can be set to handle -
HeaderConfig
-
Type:
- Object
'static': static header, the normal case, the header is rendered to the top of the grid.'sticky': sticky header, the header will stick to the viewport with a given offset.'fixed': fixed header, the header will be outside the viewport. Only the body and footer are scrollable.
Properties:
Name Type Description typestring the header type. It can have the following values
offsetnumber | function special configuration for sticky header indicating its position. It's can be a number or a function returning a number, represents number of pixels below the viewport top.
-
NormalizedOrderByPair
-
A [key: string, direction: number] pair.
Type:
- array
-
OrderByCallback(direction)
-
Parameters:
Name Type Description directionnumber The direction of the order by item
Returns:
- Type
- OrderByConfig
-
OrderByConfig
-
The order-by configuration for the data source.
Type:
- OrderByItem | Array.<OrderByItem>
-
OrderByItem
-
A single order-by item with key and direction.
Type:
-
OrderByKey
-
Represents an order by key
- When it's a string, it's the key path of the sorting value.
- When it's a callback, it takes a direction, and return a normalized order config.
Type:
- string | OrderByCallback
-
OrderByObject
-
Type:
- object
Properties:
Name Type Description keyOrderByKey The key off the order by item
directionnumber The direction of the order by item, positive for ascending, non-positive for descending
-
OrderByPair
-
A [key: OrderByKey, direction: number] pair.
Type:
- array
-
ProjectionDefinition
-
Type:
- Object
Properties:
Name Type Description namestring name of the projection
handlerProjectionHandler The callback to transform the state
defaultsObject The default configuration of the projection
normalizefunction The callback to normalize the projection configurations.
-
ProjectionHandler(state, config)
-
Parameters:
Name Type Description stateDataChainState | StructureChainState | ContentChainState The input state.
configObject The projection configuration object.
Returns:
The output state or the
Promiseof the output state.- Type
- DataChainState | StructureChainState | ContentChainState | Promise
-
PropertyCallback(item [, value])
-
It behaves as a PropertyGetter when passed 1 argument, and behaves as a PropertySetter when passed 2 arguments.
Parameters:
Name Type Argument Description itemObject The data item.
value<optional>
The new value for the property.
Returns:
- The value for the property.
-
PropertyConfig
-
Type:
- Object
Properties:
Name Type Description getPropertyGetter The getter function.
setPropertySetter The setter function.
-
PropertyGetter(item)
-
Parameters:
Name Type Description itemObject The data item.
Returns:
- The value for the property.
-
PropertySetter(item, value)
-
Parameters:
Name Type Description itemObject The data item.
valueThe value for the property.
-
QueryConfig
-
The data source configurations.
Type:
- Object
Properties:
Name Type Description orderbyOrderByConfig The sorting parameter.
filterObject The filter object in MangoDB format.
skipnumber The number of item to skip from the query result.
takenumber The number of item to take from the query result.
-
RowConfig
-
Configuration for a row. It can be an object or a special
Type:
- string | Object
'data-rows'. A row configuration which will be expanded into multiple rows representing each of the data items.'data'. Indicating the row is expanded from the'data-rows'.
Properties:
Name Type Argument Description typestring <nullable>
Optional parameter to define the type of the row. Special values are
classesClassesConfig <nullable>
The classes of the
TRelement.attributesAttributesConfig <nullable>
The attributes of the
TRelement.itemObject <nullable>
The data item for the row.
htmlstring <nullable>
The HTML string rendered in a cell taking the entire row.
viewBackbone.View <nullable>
The Backbone View take the place of the entire row. This is is only for the header and footer rows.
-
RowContent
-
Extends the RowConfig with extra properties
Type:
Properties:
Name Type Description cellsArray.<CellContent> The cells in the row.
attributesObject.<string, string> The HTML attributes for the
TRelement. -
RowsConfig
-
The configuration for rows projection. When defining header rows, it can be a special string
'column-header-rows', representing all the column header rows.Type:
- string | Object
Properties:
Name Type Description headRowsArray.<RowConfig> Row configurations for
THEAD. It can take a special string valuecolumn-header-rows, which will be expanded into the column headers.bodyRowsArray.<RowConfig> Row configurations for
TBODY. It can take a special row with typedata-rows. This row will be expanded, one for each data item.footRowsArray.<RowConfig> Row configurations for
TFOOT. -
ScrollingConfig
-
Type:
- Object
Properties:
Name Type Description virtualizedboolean flag for virtualization.
viewportstring | HTMLElement | jQuery | window the scrolling viewport. If omit, the table view will auto detect the closest ancestor of the $el with 'overflowY' style being 'auto' or 'scroll'. Use the window viewport if found none.
NOTE: the viewport takes no effect when using fixed header. Tables with fixed header render its viewport inside, as the container of the body and footer.
headerstring | HeaderConfig the header scrolling behavior configurations. It can be a string to indicate the header type (
'static','sticky'or'fixed'). Or an detailed configuration object. -
SelectableCallback(item)
-
Callback to decide whether a row is selectable.
Parameters:
Name Type Description itemObject The data item of the row.
Returns:
- Type
- boolean
-
SelectionConfig
-
Type:
- Object
Properties:
Name Type Description enabledboolean Whether the selection feature is enabled.
singleboolean True if only 1 row can be selected at the same time.
selectedArray.<string> The primary key of rows being selected.
selectableSelectableCallback A callback to decide whether a row is selectable.
colClassesClassesConfig The classes of the 'COL' element for the selection column.
headClassesClassesConfig The classes of the 'TH' element in 'THEAD' of the selection column.
bodyClassesClassesConfig The classes of the 'TD' elements in 'TBODY' of the selection column.
footClassesClassesConfig The classes of the 'TD' elements in 'TFOOT' of the selection column.
-
SetRowsCallback(rows)
-
Parameters:
Name Type Description rowsArray.<RowConfig> The current row configurations.
Returns:
- The new row configurations.
- Type
- Array.<RowConfig>
-
SortableConfig
-
Type:
- Object
- A string, the key path of the sorting values.
- A PropertyGetter to get the sorting values from data items. Only available for memory data source.
- A number A number indicating the order on first click. Positive for ascending, otherwise descending.
- An array of numbers Indicating the sequence of sorting orders.
Properties:
Name Type Description keystring | PropertyGetter The sort key. It could be
directionnumber | Array.<number> The direction could be
templateSortableHeaderTemplate A customized template to render the sortable column header.
-
SortableHeaderConfig
-
Type:
- Object
Properties:
Name Type Argument Description namestring The name of the ordered column.
directionIndexnumber The index of direction in the direction sequence.
templateSortableHeaderTemplate <nullable>
The template to render the sortable column headers.
-
SortableHeaderTemplate(locals)
-
Parameters:
Name Type Description localsObject Properties
Name Type Description htmlstring The original HTML string for the column header.
directionnumber The sort state.
- Positive value for ascending.
- Negative value for descending.
- 0 for not sorted.
-
StructureChainState
-
It extends the DataChainState with extra properties.
Type:
Properties:
Name Type Description columnsArray.<ColumnConfig> The array of column configurations.
headRowsArray.<RowConfig> The row configurations for
THEAD.bodyRowsArray.<RowConfig> The row configurations for
TBODY.footRowsArray.<RowConfig> The row configurations for
TFOOT.