tablesorter icon indicating copy to clipboard operation
tablesorter copied to clipboard

widget-formatter is not working as expected

Open pavelsr opened this issue 6 years ago • 1 comments

If I set params at widgetOptions.formatter_colum at tablesorter initialization and run widget after some event triggered as

$.tablesorter.addWidget('formatter');
$.tablesorter.applyWidget($("#jquery-table"));

widget-formatter is not working

Example: https://jsfiddle.net/serikov/8ua5djcp/ (if uncomment string everything is ok)

Also I can't use it with widget.format, got TypeError: widget.format is not a function error - https://jsfiddle.net/serikov/odc9w137/

pavelsr avatar Jan 11 '20 19:01 pavelsr

Hi @pavelsr!

Sorry for taking so long to respond!

The problem is that the widgets option also needs to include the formatter (updated demo):

$("#run_formatter").change(function() {
  console.log("Change");
  if (this.checked) {
    console.log("addWidget formatter");
    $("table")[0].config.widgets.push("formatter"); // add this line
    $.tablesorter.addWidget($.tablesorter.getWidgetById("formatter"));
    $.tablesorter.applyWidget($("#jquery-table"));
    $.tablesorter.refreshWidgets($("#jquery-table"));
  }
});

Mottie avatar Mar 03 '20 12:03 Mottie