Constructor
new AGGrid(id, columns, keyColumn)
Create a new AGGrid instance.
The HTML portion of this should look like:
CSS
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)
Add a grid to the current context.
Parameters:
Name | Type | Description |
---|---|---|
grid |
(static) date(params) → {string}
Format for date times formatted as mm/dd/yyyy
Usage: in columnDefs: valueFormatter: AGGrid.date
Usage: in columnDefs: valueFormatter: AGGrid.date
Parameters:
Name | Type | Description |
---|---|---|
params |
Returns:
- Type
- string
(static) dateTime(params) → {string}
Format for date times formatted as mm/dd/yyyy hh:mm AM/PM
Usage: in columnDefs: valueFormatter: AGGrid.dateTime
Usage: in columnDefs: valueFormatter: AGGrid.dateTime
Parameters:
Name | Type | Description |
---|---|---|
params |
Returns:
- Type
- string
(static) newGridContext()
Create a new grid context.
(static) numericFormat(params) → {string}
Format a numeric field
Usage: in columnDefs: valueFormatter: AGGrid.numericFormat, mask: 'xxx', decimalPlaces: N
Usage: in columnDefs: valueFormatter: AGGrid.numericFormat, mask: 'xxx', decimalPlaces: N
Parameters:
Name | Type | Description |
---|---|---|
params |
Returns:
- Type
- string
(static) popAllGridContexts()
Destroys all popup and screen grids that have been created
(static) popGridContext()
Destroy all grids in last context and remove the context
(static) time(params) → {string}
Format times as HH:MM AM/PM
Usage: in columnDefs: valueFormatter: AGGrid.time
Usage: in columnDefs: valueFormatter: AGGrid.time
Parameters:
Name | Type | Description |
---|---|---|
params |
Returns:
- Type
- string
addComponent(tag, cls) → {AGGrid}
Add a class that defines special cell formatting.
Parameters:
Name | Type | Description |
---|---|---|
tag |
||
cls |
Returns:
- Type
- AGGrid
addRecord(data) → {AGGrid}
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
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}
Add an array of records to the grid.
Note that this method is far faster than a series of
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}
Erase all the rows in the grid.
Returns:
- Type
- AGGrid
clearSelection() → {AGGrid}
Clear the selection from the currently selected rows.
Returns:
- Type
- AGGrid
columnShow(colId, val) → {boolean}
Hide or show column colId.
Parameters:
Name | Type | Description |
---|---|---|
colId |
||
val |
boolean | true=show, false=hide |
Returns:
previous value
- Type
- boolean
deleteRow(id) → {AGGrid}
Delete the row who's key column is equal to
id
.
Parameters:
Name | Type | Description |
---|---|---|
id |
Returns:
- Type
- AGGrid
deleteRowIndex(n) → {AGGrid}
Delete row at index
n
.
Parameters:
Name | Type | Description |
---|---|---|
n |
Returns:
- Type
- AGGrid
deleteSelectedRows() → {AGGrid}
Delete the selected rows.
Returns:
- Type
- AGGrid
deselectAll() → {AGGrid}
De-select all rows.
Returns:
- Type
- AGGrid
destroy()
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.
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)
Disables the clicks on the AGGrid control.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
flg |
boolean |
true
|
true=disable, false=enable |
enable(flg)
Enables the clicks on the AGGrid control.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
flg |
boolean |
true
|
true=enable, false=disable |
getAllRows() → {array}
Returns all the rows.
Returns:
- Type
- array
getFirstRow() → {*|null}
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}
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}
Returns the number of rows in the grid.
Returns:
- Type
- number
getRowAtIndex(n) → {*}
Get row at index
n
(indexes are zero origin)
Parameters:
Name | Type | Description |
---|---|---|
n |
Returns:
- Type
- *
getSelectedRow() → {*}
Return the selected row or
null
if none is selected.
Returns:
- Type
- *
getSelectedRowIndex() → {null|number}
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}
Return an array of the indexes of all of the selected rows.
Returns:
- Type
- array
getSelectedRows() → {*}
Return an array containing all of the selected rows.
Returns:
- Type
- *
highlightRows(idx)
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.
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}
Return
true
if the grid is empty.
Returns:
- Type
- boolean
multiSelect() → {AGGrid}
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}
Disallow any row selection. This must be called before
show()
Returns:
- Type
- AGGrid
numberOfSelectedRows() → {*}
Returns the number of selected rows
Returns:
- Type
- *
rowStyleFunction(fun) → {AGGrid}
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}
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}
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}
Execute function
fn
whenever the user double-clicks on a row.
Parameters:
Name | Type | Description |
---|---|---|
fn |
function |
Returns:
- Type
- AGGrid
setOnSelectionChanged(fn)
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}
Initialize and show the grid.
Important! Once this is called, you must call the
Important! Once this is called, you must call the
destroy()
method when the grid is no longer needed.
Returns:
- Type
- AGGrid
updateSelectedRecord(row) → {AGGrid}
Update the selected row with the new data provided in
row
.
Parameters:
Name | Type | Description |
---|---|---|
row |
Returns:
- Type
- AGGrid