I have a tablesorter with some data. I'm using Twig templates from Symfony Framework.
I'll make a basic example:
<table id="tablesorter" class="hideAtFirst tablesorter hover-highlight focus-highlight">
<!-- HEADER -->
<thead class="tablesorter-blue" id="tablesorterHeader">
<tr class="warning">
<th class="text-center">ID</th>
<th class="text-center" title="comment_short">Comment</th>
<th class="filter-false hidden" title="comment"></th>
</tr>
</thead>
<!-- BODY -->
<tbody>
<tr>
<td>1</td>
<td>This is a [...]</td>
<td>this is a long comment</td>
</tr>
</tbody>
I'm trying to display the content of 'comment' as a short text. For that I'm using slice but i want to still be able to sort by the full comment content from the short column.
If comment's value is 'This is a long test', the second column shows 'This is a [...]' and if i try to filter the table by the word 'test' it won't show the result. The 3 column with the full text has to be hidden. How can i filter the second column with the content of the 3 one?
This is what I've tried:
widgetOptions: {
resizable: true,
resizable_widths: sizes,
filter_defaultAttrib: 'data-value',
filter_saveFilters: true,
saveSort: true,
filter_functions: {
1: function (e, n, f, i) {
const query = f.toLowerCase(); //filter content from short comment
const columnIndex = i + 1; //long comment column
// Use the content from short comment to filter results from long comment column
return true;
}
}
}
I'm not sure how to proceed or if I'm asking the wrong questions.
EDIT: Changed twig template to html. Now let's suppose that the short text comes from the query with something like SUBSTRING(comment, 10, LEN(comment) ). To limit the text to 10 characters.