Hi,
thanks for your question, and sorry for the trouble.
Unfortunately, using that moment.js library is not yet possible with DataTables within TablePress, due to how such plugins are loaded. I might add support for it in the future, but cannot guarantee it at this time.
Your best chance is probably to use the approach from https://wordpress.org/support/topic/date-order-6/ which deals with a very similar scenario.
Regards,
Tobias
hi Tobias,
Thanks for your really quick reply! That’s nice to get a fast response when one is frustrated and stuck.
I got it to work like you suggested, after some hours of struggle, mostly with my database. My table data comes from a database so I modified my SQL query to generate a new column with a date in MM/DD/YYYY format (I tried YYYY/MM/DD first as it was less work for me but apparently that format is not automatically recognized by TablePress/DataTables).
Before hiding the extra MM/DD/YYYY formatted column, which I did not want the user to see, I clicked on it’s sort header and it didn’t work–until I added the data type in the Custom Commands field. But, I also had to add the sorting-on-another-column command to the Custom Commands field. I managed to figure out how to add both and the final command is:
“columnDefs”: [ { “type”: “date”, “targets”: [ 2 ] } , { “orderData”: [ 2 ], “targets”: [ 1 ] } ]
So column 1 is the “bad date” column I want to click-sort on and column 2 is the extra MM/DD/YYYY column hidden by CSS in PluginOptions:
.tablepress .column-3 {
display: none;
}
(currently I only have one table so no table number on the tablepress class)
I just thought I’d add some details here for anyone else who might have a similar problem.
p.s. any chance you can recommend a table plugin where I can edit and add/delete rows?
Hi,
good to hear that you found a solution for this now 🙂
I’m not sure what you mean with the last question. You can edit and add/delete rows in TablePress. Or do you mean on the frontend?
Regards,
Tobias
yes, I want to have some kind of user-editable table that gets saved to the db. I also would like to be able to export the table data in .csv or some parseable format.
I see this plugin, https://wordpress.org/plugins/wp-db-table-editor, but don’t know if it’s any good and since you’re a table guru I thought you might be able to recommend something.
There’s also https://wpdatatables.com but it’s $44 and a bit overkill.
Hi,
ah, I see. No sorry, I’m not aware of table plugins that allow frontend data entry 🙁 Sorry.
Regards,
Tobias
ok, thanks anyway & for the sort fix.
Hi,
no problem! Always happy to help!
Best wishes,
Tobias