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

AJAX source - array of objects with sub-object

$
0
0
Hi,

Can datatable handle an array of object with 1 column that is a sub-onject?

I've read the example with sub-array, and i was wondering if is possible to do something like this:
(see the "details" filed, it has braces not square brackets)

 
$(document).ready(function() {
    var oTable = $('#example').dataTable( {
        "bProcessing": true,
        "sAjaxSource": "sources/objects_subarrays.txt",
        "aoColumns": [
            { "mData": "engine" },
            { "mData": "browser" },
            { "mData": "platform" },
            { "mData": "details.0" },
            { "mData": "details.1" }
        ]
    } );
} );


{
  "aaData": [
    {
      "engine": "Trident",
      "browser": "Internet Explorer 4.0",
      "platform": "Win 95+",
      "details": {
        id_details: "4",
        name_details: "X"
      }
    }
....


Why i ask you this? Because i have an entity on my db, for example "engine", that has a field that is a foreign key to an other table, for example "details"..

the db structure is:

Table Engine:
engine char
browser char
platform char
id_details integer

Table Details:
id  integer
name char

Assuming the db structure above, i've created 2 java class, one for "engine" and one for "details". The "engine" class have the filed id_details defined as "details class".

when i send the json to the datatable, the "details" filed it's formatted with braces because it's an object and not a string.

Cna datatable handle this object with a sub-object?
Any suggestion on how handle this?

Kind Regards,

Stefano.

Viewing all articles
Browse latest Browse all 82439

Trending Articles



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