Judson Mitchell
Forum Replies Created
-
Peter,
Thanks very much for the offer. You are always so helpful! I went into the WP settings and see that is in fact WordPress that is modifying the date format. I changed the date format to MySQL format and the table works fine now. Presumably, I could use moment.js or date-fns to change the display format of the date after sorting, but I think I’ll take a pass on that for now.
JM
Peter,
Thanks for looking into this. In my MySQL database, the data type for this column is DATE. Data is entered in YYYY-MM-DD format. When I look at Data Explorer for this table, “Columns” has the column data type as “Date”. When I load the table in phpmyadmin, it sorts fine. On my Data Publisher produced page, I notice that JS is transforming the MySQL date format into an English string, e.g, 2019-02-01 becomes “February 1st, 2019”. That’s fine, but when I go to sort the date columns, the sort is done by the first letter of the month.
Is there somewhere else other than in the table definition that I have to set the data type for the column?
Thanks for the prompt reply, Peter. I’m looking forward to the Query Builder!
Probably so, but I am sticking with “if it ain’t broke, don’t fix it” 😉
I figured it out. Here are my table options which solve this problem:
{ "dom": "Bfrtip", "wpda_buttons": "CEFY", "wpda_searchbox": "footer", "wpda_search_placeholder_prefix": "icon", "serverSide": false, "extend": "excelHtml5", "exportOptions": { "modifier" : { "order" : "index", "page" : "all", "search" : "applied" } }, "extend": "pdfHtml5", "exportOptions": { "modifier" : { "order" : "index", "page" : "all", "search" : "applied" } }, "extend": "csvHtml5", "exportOptions": { "modifier" : { "order" : "index", "page" : "all", "search" : "applied" } }, "extend": "copyHtml5", "exportOptions": { "modifier" : { "order" : "index", "page" : "all", "search" : "applied" } } }`
Yes, Peter, it was a WP version problem. Updating to version 5+ fixed it. Thanks.
The plugin is only designed to work for Data Publisher. As far as I know, Data Projects does not afford you the opportunity to add custom JS to its views.
The plugin is still working for me using v3.1.5 of WPDA (Publisher). I would suggest open up Developer Tools and sharing with us whatever errors you see in the console.
Solved it. It turns out dashicons are only loaded on admin pages. To add them to non-admin pages, I pasted the following into my theme’s functions.php:
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' ); function load_dashicons_front_end() { wp_enqueue_style( 'dashicons' ); }Perfect. In case anybody needs this in the future, I put together a Github repo with the code: https://github.com/judsonmitchell/wp-data-access-buttons
Thanks for checking in on this Peter! I think I did basically get it going. I created a new plugin and created this function:
function add_dataTables_buttons(){ wp_enqueue_style('jquery_datatables_buttons', '//cdn.datatables.net/buttons/1.6.1/css/buttons.dataTables.min.css'); wp_enqueue_script( 'jquery_datatables_buttons', '//cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.js', array('jquery','jquery_datatables','jquery_datatables_responsive'), false, true ); } add_action( 'plugins_loaded', 'add_dataTables_buttons', 12,0 );This loads up the css and js for buttons in the right order. Unfortunately, I’ve had to hard code the version because I don’t know how to get your global WPDA::OPTION_WPDA_DATATABLES_VERSION in my function. If you have any suggestions, it would be appreciated.