Conflict with the dom-checkbox plugin and the datetime-moment plugin?
Conflict with the dom-checkbox plugin and the datetime-moment plugin?
mtindall
Posts: 10Questions: 1Answers: 0
I'm trying to use the dom-checkbox plugin on a datatable, but i also use datetime-moment for other columns sorting. The dom-checkbox doesn't seem to work unless I remove the datetime-moment calls.
I have:
$.fn.dataTable.moment('MM/DD/YYYY');
$.fn.dataTable.moment('MM/DD/YYYY hh:mm A');
and then use of dom-checkbox
I tried adding the dom-checkbox plugin both before and after these moment calls, but get the same result.
Any ideas? I really need to use both on the same table.
This discussion has been closed.
Replies
Its hard to say without seeing what you are trying to do. In order to help debug please post a test case replicating your issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
http://live.datatables.net/fuyafufo/1/edit
Here's a test case.
If you remove the top to lines of js:
$.fn.dataTable.moment('MM/DD/YYYY');
$.fn.dataTable.moment('MM/DD/YYYY hh:mm A');
the checkbox sorting works fine. But in my real life scenario, I need these lines, because there's columns in the table that I need these for
You don't appear to be including the moment js file.
https://momentjs.com/
http://live.datatables.net/qahezuta/1/edit
I didn't add moment js to the test case, but have it in my real project. Above link has moment js file added, same issue.
Thats an interesting issue. If you use the code Completed Plugin code from the Ultimate Date/Time Sorting blog the dom-checkbox sorting works. For example:
http://live.datatables.net/seqiyafe/1/edit
However the latest plugin looks to have some changes in how it determines which columns to use the moment plugin on. It strips HTML tags and white space and returns the moment format if the result is empty, which is the case with your checkbox column.
You can either use the original plugin code from the blog or add
columns.type
to the checkbox column and set it to string. The later is probably what you will want to do and is shown in the Live DOM Ordering example for the text column.Here is your updated example with the current moment plugin placed in the JS so you can see some console.log output. Plus it has the
columns.type
set which you can comment out to test.http://live.datatables.net/gukacofi/1/edit
Kevin