Ordering complex types with multiple dataTables

Ordering complex types with multiple dataTables

h.nijkamp17h.nijkamp17 Posts: 10Questions: 3Answers: 0

Hi all,

I found these great examples regarding ordering columns based on complex formatted data. It works great for me.
https://datatables.net/examples/plug-ins/dom_sort.html

BUT: I found this code is not suitable for mutliple datatables on the same page. Is there any way for binding this function:
$.fn.dataTable.ext.order["myColumnType"] per datatable instance??

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited June 2019

    Hi @h.nijkamp17 ,

    I'm surprised it doesn't work for multiple tables on the same page. If you could create a test case on http://live.datatables.net , we're happy to take a look.

    Cheers,

    Colin

  • h.nijkamp17h.nijkamp17 Posts: 10Questions: 3Answers: 0

    Hi Colin,

    Thanks for replying. I am sorry for neglecting this post, but setting up a test and simulating the problem takes me some time. I will try to come back to you soon.

  • h.nijkamp17h.nijkamp17 Posts: 10Questions: 3Answers: 0

    Hi Colin,

    Hereby the test case:
    http://live.datatables.net/kosevena/1/
    http://live.datatables.net/kosevena/1/edit

    I accidentally created a test case thats seems to work. Both tables are perfectly ordering the data based on type=ValueList. But as I made clear in the comment line, I would like to do stuff per datatable instance differently. Binding the custom ordering function seperatly would help me out.

    I hope this is clear.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Can you just give them different names? orderDataType: "ValueList1", for example? orderDataType: "ValueList1", .

    You might also be interested in this blog post which basically attempts to solve the same issue, albeit in a slightly different way.

    Allan

  • h.nijkamp17h.nijkamp17 Posts: 10Questions: 3Answers: 0

    Hi Allen,

    Thanks for responding. I am afraid I cannot use different names. This is caused by the nature of my application. Almost everything is dynamic.

    I will try solving this by looking into the blogpost you added here.

    But a more preferable approach would be to extend each table on its own? Is there a way to do that?

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    I don't understand why you can't given them different names if they are fully dynamic.

    But a more preferable approach would be to extend each table on its own? Is there a way to do that?

    Sort of. You can create type sorting plug-ins and then assign that type name to columns.type which is done on a per table basis. But the auto detection is easier to use, as described in the blog post.

    Allan

  • h.nijkamp17h.nijkamp17 Posts: 10Questions: 3Answers: 0

    Hi Allen and Colin,

    I think I have found a workaround. Thanks to the other blog example you posted earlier.

    Thanks so much!

This discussion has been closed.