Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Yikes! Sorry about that.

    To avoid corrupting functions.php, try using a snippets plugin such as this one, which allows you to safely activate and deactivate pieces of code. Where did you put moment.js and datetime-moment.js? I put them in a “js” folder in my WP installation root directory, and it works fine.

    And in case it wasn’t clear, the jQuery code should be called from a JavaScript file or added to the theme using a <script> tag, and NOT added as a snippet to functions.php… ??

    Also, I stumbled upon another solution to the date format issue. Have a look at the “date-eu” type, it might be simpler.

    I was able to run shortcodes included in the columns by adding this filter to functions.php:

    function run_shortcode ($html) {
      return do_shortcode( make_clickable($html) );
    }
    
    add_filter('gdoc_table_html', 'run_shortcode');

    Hope this helps.

    Hey Yaara,
    had the same issue, found a solution here:
    https://datatables.net/plug-ins/sorting/datetime-moment

    Basically, the default supported date format is YYYY/MM/DD. In order to support a DD/MM/YYYY format you’d have to load moment.js & datetime-moment.js . If you’re using WordPress, you can enqueue them by adding this snippet to your functions.php (just be sure to place the JS codes in the right folder):

    wp_enqueue_script( 'moment', '/js/moment.js', array ( 'jquery' ), 1.1, true);
    wp_enqueue_script( 'datetime', '/js/datetime-moment.js', array ( 'moment' ), 1.1, true);

    Then specify the format you want to support like this:

    jQuery(document).ready(function($) { 
    // needed for running jquery in a WordPress environment
    
    $(document).ready(function() {
        $.fn.dataTable.moment( 'DD/MM/YYYY' );
        } );
    });
    Thread Starter lazarboy

    (@lazarboy)

    Thanks Meitar, I was inspired by your replies and found a solution, in case anyone else is interested in something similar:

    Basically, you can use classes to customize the responsiveness of the table and force columns to appear no matter what (class “all”) while forcing other columns to always be displayed as child rows (class “none”).

    I added this simple search&replace filter to modify classes of specific columns (in this example, col 8 will be forced to be a child row, while col 9 will display normally no matter what):

    function modify_cols ($html) {
    $search = array("th class=col-8", "col-9 ");
    $replace = array("th class=col-8 none", "col-9 all ");
    
    return str_replace($search, $replace, $html);
    }
    add_filter('gdoc_table_html', 'modify_cols');

    More info and additional tweaking for different screen sizes can be found here.

    • This reply was modified 7 years, 5 months ago by lazarboy.
    • This reply was modified 7 years, 5 months ago by lazarboy.
    • This reply was modified 7 years, 5 months ago by lazarboy.
    Thread Starter lazarboy

    (@lazarboy)

    (Or if there’s a simple JavaScript solution – also good ?? )

    Thread Starter lazarboy

    (@lazarboy)

    Hey Meitar, thanks for your answer.
    I tried the workaround – the result was completely deleting the existing defaults… probably because of bad syntax and formatting on my side, but perhaps a “restore defaults” option and a warning would help here.
    Anyway, I managed to restore the deaults by looking at the source code.

    I guess I didn’t really figure out what I should write in the defaults to make it work. Can you perhaps give a quick example of the default settings that would make columns G onwards to be shown as child rows automatically across all tables?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)