Okay
  Public Ticket #3805596
Default to showing last month of data
Open

Comments

  • Bruce Hooke started the conversation

    Is there a way to generate a table that, by default, shows the last month of available data, but allow people to filter this if they want to change the date range? Thank you. At the page I provided a link to above, you can see an example of what we are dealing with. I have hidden the table via CSS to just show the chart.

  • Bruce Hooke replied

    I found a solution that works for me. What I did was create a custom shortcode that uses PHP to calculate the right date range. The start date then gets fed to wpDataTables by returning do_shortcode[wpdatatable...] . In that shortcode I include the VAR1 placeholder, set to the start date I need to use. This then gets used in the SQL Query that collects the data. I don't care about the end date because my data are always past data so in the SQL I just need to filter for dates later than the start date. Ideally I'd have this start date show up in the filter form above the table but that's less important. But if you are collecting ideas for new features, it would be great if %VAR1% could be inserted as the default start date.