-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
widgets do not take parsers into consideration #1547
Comments
Hi @dmarra! The var myTextExtraction = function(node, table, cellIndex) {
return cellIndex === 3
? // input in 4th column
$(node).find("input").val()
: $(node).find("selector").text();
};
$(function() {
$("#myTable").tablesorter({
textExtraction: myTextExtraction
});
}); As for the output widget... what if I set up the If that won't work, you can use output_formatContent : function( c, wo, data ) {
var column = data.$cell[0].cellIndex;
if (column === 3) {
return $.tablesorter.getParserById("myCustomParser").format(data.$cell.text());
}
} |
Oohhhh. I had no idea you could define just a callback for textExtraction; I don't think the documentation demonstrates that ability. That is good to know. It would work for me, if the output widget also respects the output of the callback. As far as output_formatContent, it would definitely go a long way if you could provide the parsed content to it as well. then, all I need to do is make a small callback to return the parsed value. that would be awesome! I am not sure I can get by with just getParserById(), because each column uses a different parser (defined with data- tags). It could work if I can get the name of the parser for that particular field though.... |
The master branch has been updated. Use output_formatContent : function(config, widgetOptions, data) {
// data.isHeader (boolean) = true if processing a header cell
// data.$cell = jQuery object of the cell currently being processed
// data.content = processed cell content (spaces trimmed, quotes added/replaced, etc)
// data.columnIndex = column in which the cell is contained
// data.parsed = cell content parsed by the associated column parser
return data.parsed;
}, It'll be available in the next release. |
This was added in v2.30.5; v2.30.7 was just released. |
In my current project, there are a LOT of tables. Each one contains form input fields in some of the columns.
In order to extract the text out of them, I add a parser once in a js file (textExtract option isn't sufficient since it is per column, and I would have to write that code over and over for each table since the columns are not guaranteed to be the same in each one). this fixes all my sorter problems universally.
I ALSO use the output widget on most of these tables. What I am unfortunately forced to do is duplicate the code I use for the parser and place it in "output_formatContent" option (otherwise the fields with inputs have no output data in them). This means I have to maintain the same code in two places.
It would be nice if the "parsed" option wasn't just filter widget specific. OR, if we could define that widgets should use different parsers. something like:
Just SOME way to be able to apply a parser to a widget
The text was updated successfully, but these errors were encountered: