Christopher Christopher - 3 months ago 9
Javascript Question

DataTables initialization keywords different with official examples

I'm new to DataTables due to new requirements of a project. I've started to learn it, but I'm confused about the inconsistency between the official site examples and the real usages.

Specifically, I wonder why the name of the options when initialize datatables could be always different between the official examples and practical use. For example, in official guides, initializing table with static data is demonstrated as follow:

$('#example').DataTable( {
data: data
} );


However, after I realised this does not work. I searched in statckoverflow so I got the solution should be

$('#example').DataTable({
"aaData": data
});


So, why they maintain the gap. Is this because of some issues like the namespace? Also, if they always different, how could I know the correct keywords of those options?

I know that this question might be stupid, but I failed to find the answer for many hours. Any help will be appreciated.

Answer

Hungarian notation aaData is used for jQuery DataTables 1.9. New camelCase naming convention data is used in jQuery DataTables 1.10+. Both are supported in jQuery DataTables 1.10+ to provide backward compatibility.

See Converting parameter names for 1.10 for more information.

Comments