I have an ag-Grid master/detail grid setup. So when the master grid row is expanded it then loads the detail grid.
See simple example: https://www.ag-grid.com/javascript-grid-master-detail/#example-simple-master-detail
This works on the basis that the data for the detail grid has already been fetched in the original json data used on the master grid.
I want to take the id
of the master grid selected row and make a 2nd HTTP service call to get the json data for the detail grid.
The simple example just sends the json data to the successCallback as follows:
getDetailRowData: function(params) {
params.successCallback(params.data.callRecords);
}
I have tried changing this method to:
getDetailRowData: function(params) {
this.http
.get(
"https://gist.githubusercontent.com/adrianwright109/37a5e37ba2382b26f42b9d12a8593878/raw/60d2ffed511262a6a2e7e54e01bffd28c3701c5e/ClientProfiles.json"
)
.subscribe(data => {
params.successCallback(data);
});
// params.successCallback(params.data.callRecords);
}
With this code I get the following error(s):
ERROR TypeError: Cannot read property 'http' of undefined
ERROR Error: ag-Grid: cannot get grid to draw rows when it is in the middle of drawing rows. Your code probably called a grid API method while the grid was in the render stage. To overcome this, put the API call into a timeout, eg instead of api.refreshView(), call setTimeout(function(){api.refreshView(),0}). To see what part of your code that caused the refresh check this stacktrace.
getDetailRowData: function(params) {
setTimeout(function() {
this.http
.get(
"https://gist.githubusercontent.com/adrianwright109/37a5e37ba2382b26f42b9d12a8593878/raw/60d2ffed511262a6a2e7e54e01bffd28c3701c5e/ClientProfiles.json"
)
.subscribe(data => {
params.successCallback(data);
});
}, 500);
// params.successCallback(params.data.callRecords);
}
With this code I get the following error:
ERROR TypeError: Cannot read property 'get' of undefined
I have a Plunker:
https://next.plnkr.co/plunk/IS5a3jKyDJJSSdh0
Has anyone achieved lazy loading the detail grid data from a web API service call?