Loading Grid Data
Summary
- AdapTable provides a Grid API function which can be used to load and reload the Grid as required
- This fully supports delayed loading (i.e. fetching data after AG Grid has initialised)
The loadGridData function in Grid API is used to provide AG Grid with a full set of row data.
Hint
- This function should be used when you want to populate AG Grid programatically at run-time
- This is very popular with delayed data scenarios - when the data is not available until after the Grid has loaded
AdapTable replaces all the current data in the Grid with the data provided in the function.
loadGridData
data: any[]voidLoads AG Grid with either initial or replacement set of data
This function triggers the Row Changed Event with a Trigger of Load.
Loading Grid Data
- This demo opens AG Grid and AdapTable with no data provided (a typical "Delayed Data" scenario)
- Initial data (JavaScript rows) is added by clicking the
Load Initial Grid Databutton in the Dashboard - A replacement set of data (TypeScript rows) can be provided by clicking the
Re-load Grid Databutton in the Dashboard - Note: You are still able to create AdapTable objects (e.g. Format Columns) in the absence of data
Try It Out
- Create a Format Column on a row (e.g. '[language]="JavaScript" ')
- Load the Data by clicking the button in the Dashboard
- Note that Format Column is applied to the loaded data
Caution
- Only use
loadGridDatato replace the whole data set if it is definitely required, or there is not alternative - Because the entire data set is replaced,
loadGridDatawill not invoke Cell or Row Flashing nor trigger Alerts
Find Out More
See Updating Grid Rows> or Updating Cells for better alternatives that update only specific cells or rows
Delaying Grid Data
All the demos in this site load the data up front as part of initialising AG Grid.
This is because they are designed to illustrate run-time features of AdapTable.
However in many advanced, real-world, scenarios lazy loading is required.
AdapTable support lazy-loading, for both Columns and row data.
Delaying Grid Data
- In this demo at startup no Columns or Data is provided
- Clicking a button starts a process that adds all the columns and data dynamically after the grid loads and then creates and sets a Layout as follows:
- after 1 second: add the new column definitions using
setAgGridColumnDefinitionsin Adaptable's Grid API - after 2 seconds: load the data using
loadGridDatain Adaptable's Grid API - after 3 seconds: create and set the Grouped Layout using
createAndSetLayoutin Layout API
- after 1 second: add the new column definitions using
- All these steps are accompanied by System Status messages