标题中的Jquery datatable下拉式筛选器排序 [英] Jquery datatable dropdown filter in header sorts
本文介绍了标题中的Jquery datatable下拉式筛选器排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在其标题上创建一个带有下拉列表框的数据表,根据框中选中的列过滤要显示的行。我修改了这里的示例列过滤示例,以显示下拉列表框标题
/ *添加表脚中每个TH元素的选择菜单* /
// $( tfoot th)。each(function(i){
$(thead th)。each(function(i){
...
它工作正常,但是当我点击下拉列表框时,它执行排序。当我在下拉列表中执行操作时可以禁用排序,当单击单元格中不属于下拉列表的任何位置时,只需触发排序。
感谢。
this.innerHTML = fnCreateSelect(oTable.fnGetColumnData(i))($($) );
$('select',this).change(function(){
oTable.fnFilter($(this).val(),i );
});
$('select',this).click(function(event){
event.stopPropagation();
});
});
$('select',this).change(function(){
oTable.fnFilter($(this).val(),i );
});
$('select',this).click(function(event){
event.stopPropagation();
});
});
I wanted to create a datatable with dropdown list box on its header which filters the rows to be displayed according to the selected column in the box. I modified the examples here column filtering example to display the dropdown list box in the header
/* Add a select menu for each TH element in the table footer */
// $("tfoot th").each( function ( i ) {
$("thead th").each( function ( i ) {
...
It works fine but it performs sorting when I click the dropdown list box. Is it possible to disable the sorting when I'm performing actions on the dropdown and just trigger sorting when I clicked anywhere in the cell which is not part of the dropdown.
Thanks.
解决方案
$("thead th").each( function ( i ) {
this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) );
$('select', this).change( function () {
oTable.fnFilter( $(this).val(), i );
} );
$('select', this).click( function (event) {
event.stopPropagation();
} );
} );
这篇关于标题中的Jquery datatable下拉式筛选器排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文