AGGrid

AGGrid

Provide a grid control.

This class is a wrapper around the public ag-grid utility. It is intended that this class be used exclusively rather than any of the raw ag-grid API. It provides a higher-level and more convenient API.

Please refer to ag-grid documentation on https://www.ag-grid.com/documentation-main/documentation.php for more information.

Constructor

new AGGrid(id, columns, keyColumn)

Source:
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>

CSS calc can be used to set the width or height so that the grid dynamically resizes when the browser window gets resized.
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

(static) addGrid(grid)

Source:
Add a grid to the current context.
Parameters:
Name Type Description
grid

(static) date(params) → {string}

Source:
Format for date times formatted as mm/dd/yyyy

Usage: in columnDefs: valueFormatter: AGGrid.date
Parameters:
Name Type Description
params
Returns:
Type
string

(static) dateTime(params) → {string}

Source:
Format for date times formatted as mm/dd/yyyy hh:mm AM/PM

Usage: in columnDefs: valueFormatter: AGGrid.dateTime
Parameters:
Name Type Description
params
Returns:
Type
string

(static) newGridContext()

Source:
Create a new grid context.

(static) numericFormat(params) → {string}

Source:
See:
  • Utils.format()
Format a numeric field

Usage: in columnDefs: valueFormatter: AGGrid.numericFormat, mask: 'xxx', decimalPlaces: N
Parameters:
Name Type Description
params
Returns:
Type
string

(static) popAllGridContexts()

Source:
Destroys all popup and screen grids that have been created

(static) popGridContext()

Source:
Destroy all grids in last context and remove the context

(static) time(params) → {string}

Source:
Format times as HH:MM AM/PM

Usage: in columnDefs: valueFormatter: AGGrid.time
Parameters:
Name Type Description
params
Returns:
Type
string

addComponent(tag, cls) → {AGGrid}

Source:
Add a class that defines special cell formatting.
Parameters:
Name Type Description
tag
cls
Returns:
Type
AGGrid

addRecord(data) → {AGGrid}

Source:
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 use addRecords().
Parameters:
Name Type Description
data object each element represents a column on the grid
Returns:
Type
AGGrid

addRecords(data) → {AGGrid}

Source:
Add an array of records to the grid.

Note that this method is far faster than a series of addRecord() calls.
Parameters:
Name Type Description
data array each element of the array is an object representing a row
Returns:
Type
AGGrid

clear() → {AGGrid}

Source:
Erase all the rows in the grid.
Returns:
Type
AGGrid

clearSelection() → {AGGrid}

Source:
Clear the selection from the currently selected rows.
Returns:
Type
AGGrid

columnShow(colId, val) → {boolean}

Source:
Hide or show column colId.
Parameters:
Name Type Description
colId
val boolean true=show, false=hide
Returns:
previous value
Type
boolean

deleteRow(id) → {AGGrid}

Source:
Delete the row who's key column is equal to id.
Parameters:
Name Type Description
id
Returns:
Type
AGGrid

deleteRowIndex(n) → {AGGrid}

Source:
Delete row at index n.
Parameters:
Name Type Description
n
Returns:
Type
AGGrid

deleteSelectedRows() → {AGGrid}

Source:
Delete the selected rows.
Returns:
Type
AGGrid

deselectAll() → {AGGrid}

Source:
De-select all rows.
Returns:
Type
AGGrid

destroy()

Source:
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.

disable(flg)

Source:
Disables the clicks on the AGGrid control.
Parameters:
Name Type Default Description
flg boolean true true=disable, false=enable

enable(flg)

Source:
Enables the clicks on the AGGrid control.
Parameters:
Name Type Default Description
flg boolean true true=enable, false=disable

getAllRows() → {array}

Source:
Returns all the rows.
Returns:
Type
array

getFirstRow() → {*|null}

Source:
Returns the first row in the grid. If there are no rows, a null is returned. Row selection is ignored.
Returns:
Type
* | null

getLastRow() → {*|null}

Source:
Returns the last row in the grid. If there are no rows, a null is returned. Row selection is ignored.
Returns:
Type
* | null

getNumberOfRows() → {number}

Source:
Returns the number of rows in the grid.
Returns:
Type
number

getRowAtIndex(n) → {*}

Source:
Get row at index n (indexes are zero origin)
Parameters:
Name Type Description
n
Returns:
Type
*

getSelectedRow() → {*}

Source:
Return the selected row or null if none is selected.
Returns:
Type
*

getSelectedRowIndex() → {null|number}

Source:
Return the index of the selected row. null is returned if no row is selected. If multiple rows are selected, the index of the first selected row is returned.
Returns:
Type
null | number

getSelectedRowIndexes() → {array}

Source:
Return an array of the indexes of all of the selected rows.
Returns:
Type
array

getSelectedRows() → {*}

Source:
Return an array containing all of the selected rows.
Returns:
Type
*

highlightRows(idx)

Source:
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.
Parameters:
Name Type Description
idx null, number, or array of numbers

isEmpty() → {boolean}

Source:
Return true if the grid is empty.
Returns:
Type
boolean

multiSelect() → {AGGrid}

Source:
By default, grids are single-row-select enabled. This method enables multi-row-select. It must be called prior to show().
Returns:
Type
AGGrid

noRowSelection() → {AGGrid}

Source:
Disallow any row selection. This must be called before show()
Returns:
Type
AGGrid

numberOfSelectedRows() → {*}

Source:
Returns the number of selected rows
Returns:
Type
*

rowStyleFunction(fun) → {AGGrid}

Source:
This method allows you to set a function that determines the style of each individual row.
Parameters:
Name Type Description
fun function
Returns:
Type
AGGrid

selectId(id) → {AGGrid}

Source:
Select the row specified in which the key column of that row is equal to id.
Parameters:
Name Type Description
id
Returns:
Type
AGGrid

setDragFunction(fun) → {AGGrid}

Source:
If a row is dragged, this function will be called when the drag operation is complete. fun is passed two arguments. The first is the row being dragged. The second is the row over which it was released.
Parameters:
Name Type Description
fun function
Returns:
Type
AGGrid

setOnRowDoubleClicked(fn) → {AGGrid}

Source:
Execute function fn whenever the user double-clicks on a row.
Parameters:
Name Type Description
fn function
Returns:
Type
AGGrid

setOnSelectionChanged(fn)

Source:
Execute fn anytime a row selection is changed.

fn is passwd an array of the selected rows.
Parameters:
Name Type Description
fn function

show() → {AGGrid}

Source:
Initialize and show the grid.

Important! Once this is called, you must call the destroy() method when the grid is no longer needed.
Returns:
Type
AGGrid

updateSelectedRecord(row) → {AGGrid}

Source:
Update the selected row with the new data provided in row.
Parameters:
Name Type Description
row
Returns:
Type
AGGrid