jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了下拉式筛选器jquery数据表大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的代码
$(document).ready(function() {
    /* Initialise the DataTable */
    var oTable = $('#example').dataTable({
        "oLanguage": {
            "sSearch": "Search all columns:"
        },"iDisplayLength": 10,"bJQueryUI": true,"sPaginationType": "full_numbers","bFilter": true,}); 

    /* Add a SELEct menu for each TH element in the table footer */
    $("thead th").each( function ( i ) {
        this.innerHTML = fnCreateSELEct( oTable.fnGetcolumnData(i) );
        $('SELEct',this).change( function () {
            oTable.fnFilter( $(this).val(),i );
        } );
    } );        
} );

我使用jquery datatables插件,它的工作完全就像这个例子:

http://www.datatables.net/release-datatables/examples/api/multi_filter_select.html

我想做的是,而不是为每个列下拉列表,我只想在一个特定的列上下拉列表.

所以我想我需要改变:

$("thead th").each( function ( i ) {

但我不知道该放什么.任何帮助将不胜感激,谢谢提前.

解决方法

如果你只需要一列,你可以做
var indexOfMyCol = 2;//you want it on the third column
$("thead th").each( function ( i ) {
    if(i === indexOfMyCol){ 
      this.innerHTML = fnCreateSELEct( oTable.fnGetcolumnData(i) );
      $('SELEct',this).change( function () {
        oTable.fnFilter( $(this).val(),i );
      } );
    }
} );

大佬总结

以上是大佬教程为你收集整理的下拉式筛选器jquery数据表全部内容,希望文章能够帮你解决下拉式筛选器jquery数据表所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。