JQuery datatables reorders columns from ajax source

I am using jQuery Datatables plugin , is it possible to reorder columns without changing the source data?

Here is an example of what I have.

Currently it is LicenseNumber, FirstName, LastName
I would like it to be FirstName, LastName, LicenseNumber

Is there a parameter that I can add to the data setup?

+3
source share
1 answer

Not quite sure I understood the question, but it might be useful:

(1) DataTables has a ColReorder plugin.

http://datatables.net/extensions/colreorder/

, .

ColReorder , datatables:

http://datatables.net/release-datatables/extensions/ColReorder/examples/predefined.html

ColReorder , HTML ( ) oColReorder.aiOrder. .


(2) , aoColumnDefs mDataProp, . ( . http://datatables.net/usage/columns)

...
"aoColumnDefs": [
    { "mDataProp": "FirstName", "aTargets": [ 0 ] },
    { "mDataProp": "LastName", "aTargets": [ 1 ] },
    { "mDataProp": "LicenseNumber", "aTargets": [ 2 ] }
],
...
+5

All Articles