lewis4u lewis4u - 13 days ago 4
Javascript Question

jQuery Tablesorter - output-widget make output like table

I am using this jQuery tablesorter:

http://tablesorter.com/docs/

https://mottie.github.io/tablesorter/docs/example-widget-output.html

$(function () {

var $table = $('table');

$('.download').click(function(){
$table.trigger('outputTable');
});

$table.tablesorter({
theme: 'blue',
widgets: ['zebra', 'output'],
widgetOptions : { output_delivery : 'd'}
});
});


and this is a simple DEMO

The problem is that when you click Get CSV the data saved in this file is all in one line. It is unreadable.

How to make it look like a table with columns, like it's already in HTML view....it doesn't have to be csv...is there maybe some other plugin that can export more readable output?

UPDATE:



Output looks like this:

enter image description here

and what i want is this:

enter image description here

Answer

I changed the separator to ;.

Modified JS:

$(function() {
  var $table = $('table');

  $('.download').click(function() {
    $table.trigger('outputTable');
  });

  $table.tablesorter({
    theme: 'blue',
    widgets: ['zebra', 'output'],
    widgetOptions: {
      output_delivery: 'd',
      output_separator: ';'
    }
  });
});

Check this: http://jsfiddle.net/abkNM/8764/