Select Filter in Table header
Select Filter in Table header
gauravguptain
Posts: 2Questions: 0Answers: 0
Hey,
I added select filter like showing in example(http://datatables.net/examples/api/multi_filter_select.html). Instead of tfoot I added that in thead. Now when I click on select box it doesn't open the drop down instead sorting is triggered.
Is there any way to suppress the click event which clicked on select box?
I added select filter like showing in example(http://datatables.net/examples/api/multi_filter_select.html). Instead of tfoot I added that in thead. Now when I click on select box it doesn't open the drop down instead sorting is triggered.
Is there any way to suppress the click event which clicked on select box?
This discussion has been closed.
Replies
When you added the select filter to the thead, what kind of markup did you use?
If you tried to add the element directly in the
that gets sorted, I think you may run into trouble:
[code]
Col 1 ....
Col 2 ....
Col 3 ....
[/code]
However, you may have more success if you try an approach similar to this:
[code]
Col 1
Col 2
Col 3
....
....
....
...
/* Add a select menu for each TD element in the table header */
$("thead td").each( function ( i ) {
this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) );
$('select', this).change( function () {
oTable.fnFilter( $(this).val(), i );
} );
} );
[/code]
when i click on the select, the table began to invoke sorting function! i don't nee it. How to prevent sorting when i click exactly on the select element and don't prevent when i click on the header ??
Thanks in advance!
[code]
.bind( 'click.DT', oData, function (e) {
if( j(e.target).is('select')){
return false;
}else{
fn(e);
n.blur(); // Remove focus outline for mouse users
}
n.blur(); // Remove focus outline for mouse users
} )
[/code]