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

aaData on server is a numeric array, on client is "column":"value" associative array.

$
0
0
Hi!
I have a problem, or better I would to understand this "magic".
I have this simple client side code:
var table = $('#document_search').dataTable({
			"bProcessing": true,
	        "bServerSide": true,
			'sAjaxSource'    : base_url("ajax/get_json/documents_search") ,
			'sPaginationType': 'full_numbers',
			'bDestroy': true,
			'aoColumns'      : [
			                    {'sTitle' : "document id","mData":'document_id'},
			                    {'sTitle' : "paper id","mData":'paper_id'}
				                    				
	
			                    ]
});

and, on server side, I use IgnitedDatatables, https://github.com/IgnitedDatatables/Ignited-Datatables/.
Ok, when I process the request on server side, IgnitedDatatables returns me an array, where aaData array contain numerica arrays.
When I json_encode this object, on client, the arrays of rows in aaData are "magically" associative.
Server side :
"aaData": [
        [
             "4",
            "170"
        ],
        [
            "5",
           "280",

        ],
        ...
    ]

on client, became associative:

"aaData": [
        [
           " paper_id" :  "4",
            "document_id" : "170"
        ],
        [
             " paper_id" :  "5",
           "document_id" : "280",

        ],
        ...
    ]
     


I wonder, how? This seems to be related to use of "mData" in aColumns.

Viewing all articles
Browse latest Browse all 81690

Trending Articles



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