Using DataTable.datetime('DD/MM/YY');
Using DataTable.datetime('DD/MM/YY');
csyu
Posts: 21Questions: 4Answers: 1
Error messages shown:
TypeError: i.datetime is not a function
Description of problem:
I'm am looking to have Datatables render a datetime column so that I can sort it correctly.
When I add DataTable.datetime('DD/MM/YY');
to my Vue page, I get the error above.
My full imports:
import moment from 'moment';
import DataTable from 'datatables.net-vue3';
import DataTablesLib from 'datatables.net';
import 'datatables.net-select';
import 'datatables.net-responsive';
DataTable.use(DataTablesLib);
DataTable.datetime('DD/MM/YY');
Thank you
This question has an accepted answers - jump to answer
Answers
It is a method of the
datatables.net
package. TryDataTablesLib.datetime
.Allan
Thanks Allan.
Not sure why it's still not working. I now have this code:
But I get the warning via a browser alert:
Moment.js is loaded properly on the page because I can do this successfully:
Any thoughts on if the DataTablesLib has another dependency to make this work?
That's a stumbling block I hadn't considered - apologies. In that context
moment
is local to that file, but DataTables is looking for it globally. I'll need to add an abstraction to DataTables to allow for that, and let it be set.At the moment what you'll need to do is assign
moment
towindow
- e.g.:should do it.
Allan
Thank you Allan, your solution worked.