Constructor
new AGGrid(id, columns, keyColumn)
- Description:
- Create a new AGGrid instance.
The HTML portion of this should look like:
<div id="grid" style="margin-top: 10px; width: 100%; height: calc(100% - 90px);"></div>
CSScalccan be used to set the width or height so that the grid dynamically resizes when the browser window gets resized.
- Create a new AGGrid instance.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | the ID of the div that represents the grid |
columns |
an ag-grid columnDefs data structure | |
keyColumn |
string | the ID of the key column (optional) |
Methods
addComponent(tag, cls) → {AGGrid}
Parameters:
| Name | Type | Description |
|---|---|---|
tag |
||
cls |
Returns:
- Type
- AGGrid
addRecord(data) → {AGGrid}
- Description:
- Add a single record to the grid.
Note that if several records are going to be added at a time, it is far faster to useaddRecords().
- Add a single record to the grid.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | each element represents a column on the grid |
Returns:
- Type
- AGGrid
addRecords(data) → {AGGrid}
- Description:
- Add an array of records to the grid.
Note that this method is far faster than a series ofaddRecord()calls.
- Add an array of records to the grid.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
array | each element of the array is an object representing a row |
Returns:
- Type
- AGGrid
clear() → {AGGrid}
Returns:
- Type
- AGGrid
clearSelection() → {AGGrid}
Returns:
- Type
- AGGrid
columnShow(colId, val) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
colId |
||
val |
boolean | true=show, false=hide |
Returns:
previous value
- Type
- boolean
deleteRow(id) → {AGGrid}
Parameters:
| Name | Type | Description |
|---|---|---|
id |
Returns:
- Type
- AGGrid
deleteRowIndex(n) → {AGGrid}
Parameters:
| Name | Type | Description |
|---|---|---|
n |
Returns:
- Type
- AGGrid
deleteSelectedRows() → {AGGrid}
Returns:
- Type
- AGGrid
deselectAll() → {AGGrid}
Returns:
- Type
- AGGrid
destroy()
- Description:
- Free all of the internal data structures associated with the grid.
This method must be called once a grid is no longer needed.
Please note that this function is normally handled by the framework. If your application code is calling it, you are most likely doing something wrong.
- Free all of the internal data structures associated with the grid.
- Source:
disable(flg)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
flg |
boolean |
true
|
true=disable, false=enable |
enable(flg)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
flg |
boolean |
true
|
true=enable, false=disable |
getAllRows() → {array}
Returns:
- Type
- array
getFirstRow() → {*|null}
- Description:
- Returns the first row in the grid. If there are no rows, a
nullis returned. Row selection is ignored.
- Returns the first row in the grid. If there are no rows, a
- Source:
Returns:
- Type
- * | null
getLastRow() → {*|null}
- Description:
- Returns the last row in the grid. If there are no rows, a
nullis returned. Row selection is ignored.
- Returns the last row in the grid. If there are no rows, a
- Source:
Returns:
- Type
- * | null
getNumberOfRows() → {number}
Returns:
- Type
- number
getRowAtIndex(n) → {*}
Parameters:
| Name | Type | Description |
|---|---|---|
n |
Returns:
- Type
- *
getSelectedRow() → {*}
Returns:
- Type
- *
getSelectedRowIndex() → {null|number}
- Description:
- Return the index of the selected row.
nullis returned if no row is selected. If multiple rows are selected, the index of the first selected row is returned.
- Return the index of the selected row.
- Source:
Returns:
- Type
- null | number
getSelectedRowIndexes() → {array}
- Description:
- Return an array of the indexes of all of the selected rows.
- Source:
Returns:
- Type
- array
getSelectedRows() → {*}
Returns:
- Type
- *
highlightRows(idx)
- Description:
- Highlight a row or an array of particular rows.
Note that highlighting a row and selecting a row are two different things.
Pass row index or an array or row indexes to highlight. Pass null to un-highlight all rows.
- Highlight a row or an array of particular rows.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
idx |
null, number, or array of numbers |
isEmpty() → {boolean}
Returns:
- Type
- boolean
multiSelect() → {AGGrid}
- Description:
- By default, grids are single-row-select enabled. This method enables multi-row-select.
It must be called prior to
show().
- By default, grids are single-row-select enabled. This method enables multi-row-select.
It must be called prior to
- Source:
Returns:
- Type
- AGGrid
noRowSelection() → {AGGrid}
- Description:
- Disallow any row selection. This must be called before
show()
- Disallow any row selection. This must be called before
- Source:
Returns:
- Type
- AGGrid
numberOfSelectedRows() → {*}
Returns:
- Type
- *
rowStyleFunction(fun) → {AGGrid}
- Description:
- This method allows you to set a function that determines the style of each individual row.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fun |
function |
Returns:
- Type
- AGGrid
selectId(id) → {AGGrid}
- Description:
- Select the row specified in which the key column of that row is equal to
id.
- Select the row specified in which the key column of that row is equal to
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
Returns:
- Type
- AGGrid
setDragFunction(fun) → {AGGrid}
- Description:
- If a row is dragged, this function will be called when the drag operation is complete.
funis passed two arguments. The first is the row being dragged. The second is the row over which it was released.
- If a row is dragged, this function will be called when the drag operation is complete.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fun |
function |
Returns:
- Type
- AGGrid
setOnRowDoubleClicked(fn) → {AGGrid}
- Description:
- Execute function
fnwhenever the user double-clicks on a row.
- Execute function
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function |
Returns:
- Type
- AGGrid
setOnSelectionChanged(fn)
- Description:
- Execute
fnanytime a row selection is changed.
fnis passwd an array of the selected rows.
- Execute
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function |
setRowData(data) → {AGGrid}
Parameters:
| Name | Type | Description |
|---|---|---|
data |
array | the data to display in the grid |
Returns:
- Type
- AGGrid
show() → {AGGrid}
- Description:
- Initialize and show the grid.
Important! Once this is called, you must call thedestroy()method when the grid is no longer needed.
- Initialize and show the grid.
- Source:
Returns:
- Type
- AGGrid
updateSelectedRecord(row) → {AGGrid}
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Returns:
- Type
- AGGrid
(static) addGrid(grid)
Parameters:
| Name | Type | Description |
|---|---|---|
grid |
(static) date(params) → {string}
- Description:
- Format for date times formatted as mm/dd/yyyy
Usage: in columnDefs: valueFormatter: AGGrid.date
- Format for date times formatted as mm/dd/yyyy
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
Returns:
- Type
- string
(static) dateTime(params) → {string}
- Description:
- Format for date times formatted as mm/dd/yyyy hh:mm AM/PM
Usage: in columnDefs: valueFormatter: AGGrid.dateTime
- Format for date times formatted as mm/dd/yyyy hh:mm AM/PM
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
Returns:
- Type
- string
(static) newGridContext()
(static) numericFormat(params) → {string}
- Description:
- Format a numeric field
Usage: in columnDefs: valueFormatter: AGGrid.numericFormat, mask: 'xxx', decimalPlaces: N
- Format a numeric field
- Source:
- See:
-
- Utils.format()
Parameters:
| Name | Type | Description |
|---|---|---|
params |
Returns:
- Type
- string
(static) popAllGridContexts()
(static) popGridContext()
(static) time(params) → {string}
- Description:
- Format times as HH:MM AM/PM
Usage: in columnDefs: valueFormatter: AGGrid.time
- Format times as HH:MM AM/PM
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
Returns:
- Type
- string