Constructor
new Datagrid(container, config)
Creates a new instance of the data grid
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
HTMLElement | Container where to append the data grid |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config |
Object | Config of the data grid Properties
|
Extends
Methods
addData(data) → {portal.Datagrid}
Add arbitrary data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<Object> | Arbitrary data |
Returns:
Return the datagrid
- Type
- portal.Datagrid
addEventListener(name, fn)
Register a new event.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the event. |
fn |
function | Function to trigger on event. |
- Inherited From:
- Mixes In:
append(dataItem) → {portal.Datagrid}
Append a new data item in the grid and in the data
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item to append in the grid |
Fires:
Returns:
Returns the datagrid
- Type
- portal.Datagrid
contains(dataItem, text) → {Boolean}
Returns true when the text is contained into the data item
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item where to search |
text |
String | Text to search |
Returns:
True if the text is contains
- Type
- Boolean
createCellContentElement(cellValue, dataItem, column) → {HTMLElement}
Create an element to add in the cell
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cellValue |
Object | Item use to create the content Properties
|
||||||||||||||||
dataItem |
Object | Data item associated with the column value |
||||||||||||||||
column |
Object | Column associated with the data item |
Returns:
Element to append in the cell
- Type
- HTMLElement
createRowContentElement(dataItem) → {HTMLElment}
Create a table row element for the specified data item
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item for which to creates the row |
Returns:
Table row element to append in the table
- Type
- HTMLElment
createRows(data, indentopt, statusopt) → {Object|portal.Datagrid.CreateRowsStatus}
Create all table rows using the specified data. This method could be recursive if the datagrid also act as a treeview
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data |
Array | Data for which to creates the rows |
||
indent |
Number |
<optional> |
0 | Number of recursive calls to manage the indent |
status |
CreateRowsStatus |
<optional> |
Status of the rows creation |
Returns:
-
Indicates the states of the creation
- Type
- Object
-
Status of the creations
display() → {portal.Datagrid}
Build and display the data grid
Returns:
Return the datagrid
- Type
- portal.Datagrid
emit(name, …args) → {portal.EventArg}
Event to emit.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | Event to emit. |
|
args |
* |
<repeatable> |
Arguments of the event. |
- Inherited From:
- Mixes In:
Returns:
Return the event argument.
- Type
- portal.EventArg
getCellValues(dataItem, column) → {Object|Array.<Object>}
Get the cell values of the data item.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item on which to retrieve the column value |
column |
Object | Column where to get the value |
Returns:
Values {value? , text}
- Type
- Object | Array.<Object>
getDataLength() → {Number}
Return the total number of data items. This method take in account the treeview like data.
Returns:
Length of data
- Type
- Number
getPlainText(dataItem, column) → {String}
Get the plain text of the data item for sort or search.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item on which to retrieve the text |
column |
Object | Column where to get the text |
Returns:
Plain text
- Type
- String
getSelections() → {Array.<Object>}
Returns the list of selected items
Returns:
List of selected items.
- Type
- Array.<Object>
hideLoader()
Hide loader
hidePlaceholder()
Hide placeholder
listen() → {portal.Datagrid}
Listen the events on the table
Fires:
Returns:
Return the datagrid
- Type
- portal.Datagrid
pull(optionsopt) → {Promise}
Pull the data to display and render it.
This method require the ajaxUrl
in the config.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Options of the pull Properties
|
Returns:
Promise when the data is rendered
- Type
- Promise
query(queryopt) → {portal.Datagrid}
Apply sort, search, filter on the data grid
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
query |
Object |
<optional> |
Query to apply on the list Properties
|
Returns:
Return the datagrid
- Type
- portal.Datagrid
remove(dataItem) → {portal.Datagrid}
Remove a data item from the data grid and from the data
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item to remove |
Fires:
Returns:
Returns the datagrid
- Type
- portal.Datagrid
removeEventListener(name, fn)
Remove an event listener.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of the event to remove. |
fn |
function | Function to remove from the listener. |
- Inherited From:
- Mixes In:
search(keyword) → {portal.Datagrid}
Search the keyword to filter the datagrid
Parameters:
Name | Type | Description |
---|---|---|
keyword |
String | Keyword to search |
Returns:
Return the datagrid
- Type
- portal.Datagrid
showLoader(messageopt)
Show loader with optional message
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
String |
<optional> |
Message to display |
showPlaceholder(messageopt)
Show the placeholder with optional message
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
String |
<optional> |
Message to display |
sortData() → {portal.Datagrid}
Sort the data
Returns:
Return the datagrid
- Type
- portal.Datagrid
unselect(dataItem) → {Boolean}
Unselect a specific data item, and return true if the state has changed
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data item to unselect |
Returns:
True if the state has changed
- Type
- Boolean
update() → {portal.Datagrid}
Update the data grid using the data and the query
Fires:
Returns:
Return the datagrid
- Type
- portal.Datagrid
updateHeaderCheckbox() → {portal.Datagrid}
Update the state of the header checkbox according to the selections
Returns:
Return the datagrid
- Type
- portal.Datagrid
Type Definitions
CreateRowsStatus
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
selectionsChanged |
Boolean | Indicates if the selections has changed |
Events
addRow
Each time a row is added in the table.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data grid item which represent the row. |
append
When a data item is append in the table using the append() method.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data grid item that has been append. |
remove
When a data item is removed in the table using the remove() method.
Parameters:
Name | Type | Description |
---|---|---|
dataItem |
Object | Data grid item that has been removed. |
scrollOnLastRow
When the user scroll on the table container and reach the last display row.
Example of usage:
let offset = 0;
grid.addEventListener("scrollOnLastRow", () => {
offset++;
grid.pull({
append: true,
urlParams : {
offset : offset,
limit : 250
}
});
});
Parameters:
Name | Type | Description |
---|---|---|
datagrid |
portal.Datagrid | The current datagrid. |
selectionChange
When the selection changed.
Parameters:
Name | Type | Description |
---|---|---|
selections |
Array.<Object> | List of selections |
update
When the datagrid was updated.
Parameters:
Name | Type | Description |
---|---|---|
datagrid |
portal.Datagrid | The current datagrid. |