Constructor
new ModernTable(tableContainerID, tableID, dataURL, optionsopt)
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tableContainerID |
string | The ID of the element that contains the table. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tableID |
string | The ID we want to assign to the table. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dataURL |
string | URL used to fetch JSON data to build table. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional configuration object. Properties
|
- Source:
Methods
(async, private) _buildTable()
Builds the table by fetching the data & rendering the table in the GUI.
- Source:
(async, private) _buildTable()
Builds the table by fetching the data & rendering the table in the GUI.
- Source:
(private) _cancelSearch(e)
Provides a method for canceling a search.
Parameters:
Name | Type | Description |
---|---|---|
e |
event |
- Source:
(private) _cancelSearch(e)
Provides a method for canceling a search.
Parameters:
Name | Type | Description |
---|---|---|
e |
event |
- Source:
(async, private) _fetchData(urlToBeFetched) → {Array.<Object>}
Fetches data and renders table if data was successfully fetched.
Parameters:
Name | Type | Description |
---|---|---|
urlToBeFetched |
string |
- Source:
Returns:
responseJSON
- Type
- Array.<Object>
(async, private) _fetchData(urlToBeFetched) → {Array.<Object>}
Fetches data and renders table if data was successfully fetched.
Parameters:
Name | Type | Description |
---|---|---|
urlToBeFetched |
string |
- Source:
Returns:
responseJSON
- Type
- Array.<Object>
(private) _filterTable(e, rows)
Loops through each cell in each row and checks if matches searchText.
Parameters:
Name | Type | Description |
---|---|---|
e |
event | |
rows |
array | rows collection of a table element |
- Source:
(private) _filterTable(e, rows)
Loops through each cell in each row and checks if matches searchText.
Parameters:
Name | Type | Description |
---|---|---|
e |
event | |
rows |
array | rows collection of a table element |
- Source:
(private) _formatCellValue(cellValue, configKey)
Formats table cells with number and/or date formatting.
Notes:
- Recommended to use format-intl-number library or Moment.js for formatting.
- However, other formatting libraries can be used if desired.
- Gracefully fails to no number/date formatting if libraries are not loaded or the format option was not specified in the colConfig.
Parameters:
Name | Type | Description |
---|---|---|
cellValue |
* | |
configKey |
string |
- Source:
Returns:
cellValue
(private) _formatCellValue(cellValue, configKey)
Formats table cells with number and/or date formatting.
Notes:
- Recommended to use format-intl-number library or Moment.js for formatting.
- However, other formatting libraries can be used if desired.
- Gracefully fails to no number/date formatting if libraries are not loaded or the format option was not specified in the colConfig.
Parameters:
Name | Type | Description |
---|---|---|
cellValue |
* | |
configKey |
string |
- Source:
Returns:
cellValue
(private) _renderTable(tableData)
Processes fetched data into an HTML table.
Parameters:
Name | Type | Description |
---|---|---|
tableData |
Array.<Object> |
- Source:
(private) _renderTable(tableData)
Processes fetched data into an HTML table.
Parameters:
Name | Type | Description |
---|---|---|
tableData |
Array.<Object> |
- Source:
(private) _renderTableBody(elementTable, tableData)
Process fetched data into a table body.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
string | |
tableData |
Object |
- Source:
(private) _renderTableBody(elementTable, tableData)
Process fetched data into a table body.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
string | |
tableData |
Object |
- Source:
(private) _renderTableHead(elementTable, tableData)
Creates table row from fetched data's keys.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
string | |
tableData |
Array.<Object> |
- Source:
(private) _renderTableHead(elementTable, tableData)
Creates table row from fetched data's keys.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
string | |
tableData |
Array.<Object> |
- Source:
(private) _renderTableSearch(elementTable)
Creates a search as you type search element.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
Object |
- Source:
(private) _renderTableSearch(elementTable)
Creates a search as you type search element.
Parameters:
Name | Type | Description |
---|---|---|
elementTable |
Object |
- Source:
(private) _setAlignment(configKey) → {string}
Sets the alignment for a column from the alignment colConfig.
Parameters:
Name | Type | Description |
---|---|---|
configKey |
string |
- Source:
Returns:
alignment
- Type
- string
(private) _setAlignment(configKey) → {string}
Sets the alignment for a column from the alignment colConfig.
Parameters:
Name | Type | Description |
---|---|---|
configKey |
string |
- Source:
Returns:
alignment
- Type
- string
(private) _setColTitle(configKey) → {string}
Sets the column title from colTitle configuration if explicitly set.
Parameters:
Name | Type | Description |
---|---|---|
configKey |
string |
- Source:
Returns:
colTitle
- Type
- string
(private) _setColTitle(configKey) → {string}
Sets the column title from colTitle configuration if explicitly set.
Parameters:
Name | Type | Description |
---|---|---|
configKey |
string |
- Source:
Returns:
colTitle
- Type
- string