new GridView(options)
Class of a projection grid view
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The constructor options. Properties
|
Extends
- Backbone.View
Members
-
countRows :number
-
The count of data rows.
Type:
- number
-
dataSource :DataSource
-
The data source of the grid
Type:
-
itemArray :Array.<Object>
-
The array data items.
Type:
- Array.<Object>
-
items :Array.<Object>|FakeArray
-
The data items. It's a fake array of original model.
Type:
- Array.<Object> | FakeArray
-
primaryKey :string
-
The primary key of data items.
Type:
- string
-
totalCountRows :number
-
The total count of data items. This represents the server side state.
Type:
- number
Methods
-
appendBodyRows(rows)
-
Append a set body rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to append
-
appendFootRows(rows)
-
Append a set footer rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to append
-
appendHeadRows(rows)
-
Append a set header rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to append
-
columnWithName(name)
-
Get the finalized column configuration with a given column name.
Parameters:
Name Type Description namestring The name of the column.
Returns:
- Type
- ExtendedColumnConfig
-
deselectAll()
-
Deselect all the selectable items.
-
deselectRow(key)
-
Deselect a row with the given primary key.
Parameters:
Name Type Description keystring The primary key for the row.
-
get(name)
-
Read the grid(projection)_configuration
Parameters:
Name Type Description namestring name of the projection
Returns:
- Type
- object
-
getBodyRows()
-
Get the row configurations for
TBODYReturns:
- Type
- Array.<RowConfig>
-
getFootRows()
-
Get the row configurations for
TFOOTReturns:
- Type
- Array.<RowConfig>
-
getHeadRows()
-
Get the row configurations for
THEADReturns:
- Type
- Array.<RowConfig>
-
indexOfElement(el)
-
Given an element in the data rows, get the index of the corresponding data item.
NOTE: It's not recommended to use this API to find the data item for a given element. It could be incorrect if there're custom projections changes the TR sequence of TBODY. Insteadly, you should use GridView#keyOfElement.
Parameters:
Name Type Description elHTMLElement | jQuery | string The DOM element. It can be an
HTMLElement, a jQuery object or a jQuery selector.Returns:
- The index of the data row.
- Type
- number
-
itemAt(index)
-
Get the data item with its index in the items array.
Parameters:
Name Type Description indexnumber The index of the item.
Returns:
- Type
- Object
-
itemOfElement(el)
-
Get the data item from a DOM element in a certain row.
Parameters:
Name Type Description elHTMLElement | jQuery | string The DOM element. It can be an
HTMLElement, a jQuery object or a jQuery selector.Returns:
- Type
- Object
-
itemWithKey(key)
-
Query the data item with its primary key.
Parameters:
Name Type Description keystring the primary key.
Returns:
- Type
- Object
-
keyOfElement(el)
-
Get the primary key from a DOM element in a certain row.
Parameters:
Name Type Description elHTMLElement | jQuery | string The DOM element. It can be an
HTMLElement, a jQuery object or a jQuery selector.Returns:
- The primary key for the row.
- Type
- string
-
monitorViewportChange( [timeout] [, interval])
-
Monitor the viewport change during a certain period and adjust the sticky headers if necessary.
Parameters:
Name Type Argument Default Description timeoutnumber <optional>
1000 The period of monitoring in milliseconds
intervalnumber <optional>
100 The interval of sampling in milliseconds
-
patch(config, callback)
-
Patch the grid(projection) configurations. It's similar to GridView#set, but instead of replacing the projection configurations,
patchdo deep object merge.Parameters:
Name Type Description configObject.<string, Object> A hash of configurations to change. The keys are projection names while the values are the projection configurations
callbackfunction A callback to notify the update is completed
Returns:
This grid view.
- Type
- GridView
-
pipeContentProjections(projs)
-
Pipe a projection to procceed the grid visual content
Parameters:
Name Type Argument Description projsProjectionDefinition <repeatable>
A list of projection definitions
Returns:
- This grid view
- Type
- GridView
-
pipeDataProjections(projs)
-
Pipe a projection to procceed the grid data
Parameters:
Name Type Argument Description projsProjectionDefinition <repeatable>
A list of projection definitions
Returns:
- This grid view
- Type
- GridView
-
pipeStructureProjections(projs)
-
Pipe a projection to procceed the grid structure
Parameters:
Name Type Argument Description projsProjectionDefinition <repeatable>
A list of projection definitions
Returns:
- This grid view
- Type
- GridView
-
prependBodyRows(rows)
-
Prepend a set body rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to prepend
-
prependFootRows(rows)
-
Prepend a set footer rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to prepend
-
prependHeadRows(rows)
-
Prepend a set header rows
Parameters:
Name Type Description rowsArray.<RowConfig> The rows to prepend
-
query(params)
-
Make query to the data source
Parameters:
Name Type Description paramsobject The query parameters
Returns:
- Type
- QueryResult
-
refresh( [force])
-
Refresh the GridView
Parameters:
Name Type Argument Default Description forceboolean <optional>
false True for force refresh ignoring the cached states.
-
remove()
-
Destroy and detach the view from DOM.
-
render( [callback])
-
Render the grid view.
Parameters:
Name Type Argument Description callbackfunction <optional>
A callback to notify the render is completed.
Returns:
This grid view.
- Type
- GridView
-
selectAll()
-
Select all the selectable items.
-
selectedItems()
-
Get the selected items.
Returns:
- An array of the selected data items.
- Type
- Array.<Object>
-
selectedKeys()
-
Get the primary keys of the selected items.
Returns:
- An array of the selected keys.
- Type
- Array.<string>
-
selectRow(key)
-
Select a row with the given primary key.
Parameters:
Name Type Description keystring The primary key for the row.
-
set(config [, callback])
-
Change the grid(projection) configuratons
Parameters:
Name Type Argument Description configObject.<string, Object> A hash of configurations to change. The keys are projection names while the values are the projection configurations
callbackfunction <optional>
A callback to notify the update is completed
Returns:
This grid view.
- Type
- GridView
-
setBodyRows(value)
-
Set the row configurations for
TBODYParameters:
Name Type Description valueArray.<RowConfig> | SetRowsCallback The new body rows or a function to transform the body rows.
-
setFootRows(value)
-
Set the row configurations for
TFOOTParameters:
Name Type Description valueArray.<RowConfig> | SetRowsCallback The new footer rows or a function to transform the footer rows.
-
setHeadRows(value)
-
Set the row configurations for
THEADParameters:
Name Type Description valueArray.<RowConfig> | SetRowsCallback The new header rows or a function to transform the header rows.
Events
-
didRedraw
-
The
GridViewdid redraw the DOM. This event may trigger frequently when virtualization is enabled. -
didRedrawBody
-
-
didRedrawFooter
-
-
didRedrawHeader
-
-
didReload
-
The
GridViewdid reload data from the data source. This event take 2 parameters- succeeded (Boolean), true if the data fetch succeeded
- data|rejection (Object)
- If the data fetch succeeded, pass the fetched data in form of
{ totalCount, items }. WheretotalCountis the server side total item count, and the items is the array of data items with current query condition - If the data fetch failed, pass the rejection object, which is
usually an
Errorobject from the data source
- If the data fetch succeeded, pass the fetched data in form of
-
didUpdate
-
The
GridViewdid update its configuration and redraw. -
willRedraw
-
The
GridViewwill redraw the DOM. This event may trigger frequently when virtualization is enabled. -
willRedrawFooter
-
-
willRedrawHeader
-
-
willReload
-
The
GridViewwill reload data from the data source. -
willUpdate
-
The
GridViewwill update its configuration and redraw. -
wwillRedrawBody
-