Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82115

Using sAjaxDataProp with null response results in "aData is undefined"

$
0
0
Howdy:

I have sAjaxSource and sAjaxDataProp set like:

"sAjaxSource": "/rest/roles.json",
"sAjaxDataProp": "roles.assignments"

...so that my Datatable implementation uses the 'assignments' collection for its row data.

This works fine if there are values in the assignments collection. However, the REST server I'm connecting to sends back assignments as null if there are no rows available, e.g.:

{
  "roles" : null
}

And I get the following error from Datatables:

TypeError: aData is undefined

Obviously it's not happy having a null property while trying to drill down to the data. Is there any way to null check the response before handing off to Datatables?

I was actually able to get past this same problem on another project by creating a Backbone collection for the data source and then using the Backbone parse method to null check and provide an empty collection to Datatables... but I'd like to know if there's a way around it without going that far.

I love Datatables. Thanks!

NBB (Dallas, Texas)

Viewing all articles
Browse latest Browse all 82115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>