Order columns JSON server side

Order columns JSON server side

matveganmatvegan Posts: 6Questions: 0Answers: 0
edited January 2013 in General
I use datatable with dynamic columns from server side. When I reorder the columns the data is reorder but when I do a callback the columns are in the correct order but the data are in the original secuence because in server side I return the JSON in the same order.
How can I resolve this? Can I return in JSON column name and value (I try this but datatable show me an alert JSON error)?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Not sure I 100% understand, please post a link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read .

    Also consider using objects, rather than arrays, which will make ordering irrelevant: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • matveganmatvegan Posts: 6Questions: 0Answers: 0
    Can I get the columns order from dom object?
    If is possible I post this values and reorder the JSON data.
  • matveganmatvegan Posts: 6Questions: 0Answers: 0
    My idea is:
    First time I have this columns order: 0,1,2,3,4
    When I reorder the columns: 2,3,1,4,0
    If I post this numbers I can reorder the JSON.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Perfectly possible, not not built input dataTables. You'd need to add a few lines of your own code to get that information form the DOM.

    Allan
This discussion has been closed.