Custom search
Custom search
Massimo1974
Posts: 27Questions: 2Answers: 0
I'm making the filters for customized column I have columns 7 and 8 that work with select, columns 9 and 10 that work with text, columns 11 and 12 that are numerical so I need the range min and max.
otherwise I was thinking of duplicate header and put a multiselect check. can someone advise me something already working?
"initComplete": function () {
//COLONNE CON SELECT
this.api().columns([7,8]).every( function () {
var column = this;
var select = $('<select><option value="" selected>Seleziona </option></select>')
.appendTo( $(column.header()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' );
});
});
//COLONNE RICERCA TESTO
this.api().columns([9,10]).every( function () {
});
//COLONNE MIN E MAX RANGE
this.api().columns([11,12]).every( function () {
});
},
This discussion has been closed.
Replies
Hi @Massimo1974 ,
There's an example of a range search here.
Cheers,
Colin
I realized this but for the research and 1 ° does not work very well .... then I would like to put it below in a second header line
<thead>
<tr>
<td>name</td>
<td>age</td>
</tr>
</thead>
<tr id="forFilters">
<td></td>
<td></td>
</tr>
<thead>
</thead>
Hi @Massimo1974 ,
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
thanks Colin....
I would like to put the filters in the second rows and make them work
https://jsfiddle.net/ng45k1ja/2/
Thanks for that. I can't see where you've attempted to put that range search though that I linked to in my first reply.
on the first rows (head) click Name(Tutti)