This repository was archived by the owner on Feb 2, 2025. It is now read-only.
This repository was archived by the owner on Feb 2, 2025. It is now read-only.
Nested data objects don't work when loading a table via a promise. #214
Closed
Description
When loading a data table through a promise, the .withDataProp() option does not seem to work with nested objects. For example:
Options:
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function() {
return $resource('data-nested.json').get().$promise;
}).withDataProp('data.inner');
Data (data-nested.json):
{
"data": {
"inner": [
{
"id": 860,
"firstName": "Superman",
"lastName": "Yoda"
}, {
"id": 870,
"firstName": "Foo",
"lastName": "Whateveryournameis"
}, {
"id": 590,
"firstName": "Toto",
"lastName": "Titi"
}
]
}
}
Results in this error:
TypeError: Cannot convert undefined or null to object
at _doRender (angular-datatables.renderer.js:322)
at angular-datatables.renderer.js:312
at processQueue (angular.js:12984)
at angular.js:13000
at Scope.$get.Scope.$eval (angular.js:14200)
at Scope.$get.Scope.$digest (angular.js:14016)
at Scope.$get.Scope.$apply (angular.js:14304)
at done (angular.js:9518)
at completeRequest (angular.js:9703)
at XMLHttpRequest.requestLoaded (angular.js:9646)
It seems the problem is in angular-datatables.renderer.js line 309:
// In case the data is nested in an object
if (renderer.options.sAjaxDataProp) {
data = result[renderer.options.sAjaxDataProp];
}
I'll submit a pull request with a fix for this issue.