tablesorter
tablesorter copied to clipboard
widget-formatter is not working as expected
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/
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"));
}
});