So, I forked this simple ag-grid demo Plunker and the forked version is here.
The only change is that the old code statically assigned the row data for the ag-grid while my fork tries to assign i dynamically, using the API.
i
old:
var rowData = [
{make: "Toyota", model: "Celica", price: 35000},
{make: "Ford", model: "Mondeo", price: 32000},
{make: "Porsche", model: "Boxter", price: 72000}
];
// let the grid know which columns and what data to use
var gridOptions = {
columnDefs: columnDefs,
rowData: rowData,
onGridReady: function () {
gridOptions.api.sizeColumnsToFit();
}
};
new:
var rowData = [
{
make: "Toyota",
model: "Celica",
price: 35000
},
{
make: "Ford",
model: "Mondeo",
price: 32000
},
{
make: "Porsche",
model: "Boxter",
price: 72000
}
];
$scope.grid = {
columnDefs: columnDefs,
rowData: [],
rowSelection: 'single'
};
$scope.grid.api.setRowData(rowData);
Both in my Plunker, and trying this on localhost, the ag-grid does not appear.
What am I doing wrongly?
[Update] I want to get the data from a server every time the user clicks a button, not just when the grid is ready, and assign the grid's rowData using it's api.
[Upperdate] I just noticed on localhost that although $scope.gridOptions is defined, $scope.gridOptions.api is undefined