Can column.data() be made to return orthogonal data?

Can column.data() be made to return orthogonal data?

Tracy LoganTracy Logan Posts: 5Questions: 2Answers: 0

Link to test case: https://live.datatables.net/zefijaxe/1/edit?html,js,console,output

Description of problem:

I haven't been able to get the test case example to work -- the column().data() call returns an unexpected empty array (though the real code does return the expected columnar data locally). While baffling, that's not the real issue. :)

The real question seems simple enough to be answered without the working example: The expected output from the example would be the formatted dates (the default _ orthogonal data used for display): Mon 25th Apr 11, Mon 25th Jul 11, Mon 12th Jan 09, ...

Instead, is there a way to return the timestamps (the sort orthogonal data): 1303689600, 1311552000, 1231718400, ...?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949
    edited November 2023 Answer ✓

    the column().data() call returns an unexpected empty array

    The statement is executed before Datatables initialization is complete. The ajax request is asynchronous causing the Datatables init to be delayed until the response. I placed the code in initComplete to execute when fully initialized.

    is there a way to return the timestamps (the sort orthogonal data)

    Use cell().render() or cells().render() to get the orthogonal data. For example:

    table.cells(null, 1).render('sort')
    

    Where null is the row-selector parameter. A null or no selector row-selector returns all rows.

    Updated example:
    https://live.datatables.net/zefijaxe/2/edit

    Kevin

Sign In or Register to comment.