How to filter DATATABLES WITH TABLEDIT ?
How to filter DATATABLES WITH TABLEDIT ?

Hello everyone,
I need your help. I must used DATABLES WITH TABLEDIT.
In my category column, I need to have a select option with all categories.
When I need to search on my table, all rows are displayed because we have the match in the select option.
I need to filter results only on <span class="tabledit-span"> tag.
I don't know how to use regex with it.
Thanks in advance for your help.
My actual script:
var select = $('<select><option value=""></option></select>')
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
if ( table.column(i).search() !== this.value ) {
var val = this.value;
var regex = `/<span class=\"tabledit-span\">.*" + val + ".*<.*span>/`;
table
.column(i).search( val ? regex : '', true, false );
I tried with this line but
var val = "keywords";
var regex = "/<span class=\"tabledit-span\">.*" + val + ".*<.*span>/";
table.column(i).search( val ? regex : '', true, false )
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
Here my HTML source code:
<span class="tabledit-span">ASS</span><select class="tabledit-input form-control input-sm" name="coloris" style="display: none;" disabled=""><option value="0">---</option><option value="BE">BE</option><option value="BC">BC</option><option value="BL">BL</option><option value="CR">CR</option><option value="CC">CC</option><option value="DR">DR</option></select>
I need to search only on <span class="tabledit-span">ASS</span> element.
Hi @gaetanroot ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hello,
For example, when I want filter on Office column. I don't want to take the search on select element too.
Thanks in advance.
Gaëtan
Each office name are in option fields
For the first line
Edinburgh
SELECT
option
Edinburgh
option
San Francisco
option
New York
option
London
END OF SELECT
https://jsfiddle.net/juxmfqv9/
Hi @gaetanroot ,
That fiddle doesn't run. Tabledit isn't one of ours, it's a third-party library, so it would be worth addressing this with the Tabledit author or posting on Stackoverflow.
Cheers,
Colin