ColReorder with ajax-sourced DataTable

ColReorder with ajax-sourced DataTable

This question has an accepted answers - jump to answer

Answers

  • mephormephor Posts: 1Questions: 0Answers: 0

    Hi,

    i have the same problem. anyone an idea?

    best regards,
    mephor

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Two suggestions -

    Latest Versions of colreOrder
    1) When I went the fiddle in question, I upgraded dataTables to 1.9 and the colreorder to 1.2 and then everything worked as expected. I was able to drag both the column header and the column of data around.

    Named data columns in both then columns definition and in the ajax json data.
    2) My own instance, however, it still failed. I have designed my own API for setting up the table in a minimal fashion as I have dozens of tables on multiple pages. My json data always has a named column, either one I assign to it, or my class assigns it one based upon the column number, something like names of "0", "myNameColumn", "myState", "3", "4". where 0,3,4 are assigned by the class, and the "mys" are ones I named. Those json data column names must be present in the columns definition also. I always ignored them previously, but colreorder seems to need them. Bottom line, if you use column names, you must be consistent in both the definition and the json data.

  • ivictborivictbor Posts: 6Questions: 2Answers: 0
    edited January 2016

    Thanks glenderson! I tried folowing:
    1) I updated fiddle with latest versions (dt-1.10.10,cr-1.3.0): http://jsfiddle.net/Mbj9b/232/ , still have a bug if you swap first and second column and click on "ajax.reload".

    2) Adding columns name doesn't solves problem http://jsfiddle.net/Mbj9b/233/ ,

    3) but using "Ajax data source (objects)" instead of "Ajax data source (arrays)" seems solves it http://jsfiddle.net/Mbj9b/234/

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin
    Answer ✓

    Objects are always massively easier to work with than arrays with using column reordering.

    Allan

This discussion has been closed.