Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dom-checkbox plugin conflicts with datetime-moment #426

Open
MaPePeR opened this issue Feb 25, 2019 · 2 comments
Open

dom-checkbox plugin conflicts with datetime-moment #426

MaPePeR opened this issue Feb 25, 2019 · 2 comments

Comments

@MaPePeR
Copy link

MaPePeR commented Feb 25, 2019

If you have the datetime-moment plugin loaded and add a moment type the dom-checkbox plugin (and maybe others) will not work properly anymore.

This is caused by the dom-monent plugin also accepting empty strings (or strings only consisting of HTML tags) as valid dates and therefor assigning a moment date type to the column. The custom data from the dom-checkbox plugin can then not be sorted anymore, because it is not a valid date format.

I see two possible fixes:

  • don't detect empty strings as dates
  • do the format detection on the output of the custom data source plugin.
@DataTables
Copy link
Collaborator

You might also be able to reverse the order you are adding the two plug-ins since they are checked sequentially. The ability to use datetime / moment on empty strings was added in per a feature request.

Another option would be to disable the auto type detection for the column and assign the type manually.

@MaPePeR
Copy link
Author

MaPePeR commented Feb 25, 2019

Changing the order didn't help. Probably because one of them is a "type detect"($.fn.dataTable.ext.type.detect) and the other a "custom data source"($.fn.dataTable.ext.order) plugin.

One could make the empty string handling optional with a third argument to the moment function.
Having columns that have empty values default to date sorting instead of normal string sorting strikes me as kind of weird, though.

Also setting "type": "num" on the column that has "sSortDataType|orderDataType": "dom-checkbox" will probably fix it. Good idea. Maybe its useful to add this to the documentation, then? Because it did took me a lot of time, to finally figure out what the culprit was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant