• Resolved loristictok

    (@loristictok)


    for those who need to export in CSV the generated result table, this javascript/jQuery snippet does the trick:
    I personally use “CUSTOM CSS AND JS” plugin with this code set to Admin pages

    
    jQuery(document).ready(function( $ ){
      jQuery.getScript('https://cdn.jsdelivr.net/npm/[email protected]/src/table2csv.min.js', function () {
        if ($(".ELISQLREPORTS-table").length)
          {
        $('table.ELISQLREPORTS-table').each(function () {
            var $table = $(this);
            var $title = $(".ELISQLREPORTS-Report-Name")[0].textContent;
            var $button = $("<button type='button'>");
            $button.text("Export to CSV");
            $button.insertBefore($table);		
            $button.click(function () {          	
                $table.table2csv('download', { 'filename': $title + ".csv" });
            });
        });
    	}
      });
    });
    /*
    https://github.com/OmbraDiFenice/table2csv
    */
    • This topic was modified 4 years, 9 months ago by loristictok.
Viewing 1 replies (of 1 total)
  • Thanks for sharing this. It’s a great feature that should be in the core plug-in.

    For pages that have multiple reports (and I have several), I found it necessary to change the line:
    var $title = $(“.ELISQLREPORTS-Report-Name”)[0].textContent;
    to:
    var $title = $(this).siblings(“.ELISQLREPORTS-Report-Name”)[0].textContent;

    so that exported file name for every report matches its own report name (instead of them all taking the name from the first report on the page).

Viewing 1 replies (of 1 total)
  • The topic ‘Export CSV’ is closed to new replies.