简体   繁体   中英

JQuery DataTable Column Filter - select dropdown filter

At the moment, I'm trying to use a dropdown list to filter my table (I'm using Datatable plugin)

This is my code :

         $('#tableID').dataTable()
   .columnFilter({
  aoColumns: [ 
  { type: "text" },
  { type: "number" },
  { type: "select", values: [ 'Identify Proposal', 'Define Proposal',  'Evaluate', 'Pending Proposal', 'Approval']  },
  { type: "select", values: [ 'Identify Proposal', 'Define Proposal',  'Evaluate', 'Pending Proposal', 'Approval']  },
  { type: "text" },
  null,
  null,
  null,
  null,
  null,
  null,
  null,
  null
]
});
      }); 

What I'm trying to do is to get my table to have a drop-down filter : http://jquery-datatables-column-filter.googlecode.com/svn/trunk/customFilters.html

But for some reasons it's not doing what it should. I don't know what I did wrong. This is the link to my table : http://176.32.230.19/caffeine-cranked.com/Files/test.html

Maybe you've to add a type of filter for each column (13 in total). Something like this:

var path = "lib/test.csv" ;
      d3.text(path, function (datasetText) {
      var rows = d3.csv.parseRows(datasetText);
      var tbl = d3.select("#container")
          .append("table")
          .attr("id","tableID");
      // headers
      tbl.append("thead").append("tr")
        .selectAll("th")
        .data(rows[0])
        .enter().append("th")
        .text(function(d) {
            return d;
        });
       // data
      tbl.append("tbody")
        .selectAll("tr").data(rows.slice(1))
        .enter().append("tr")
        .selectAll("td")
        .data(function(d){return d;})
        .enter().append("td")
        .text(function(d){return d;})

 });

 $('#tableID').dataTable().columnFilter({
    sPlaceHolder: "head:before", 
    aoColumns: [ 
        { type: "text" },
        { type: "number" },
        { type: "select", values: [ 'Identify Proposal', 'Define Proposal',  'Evaluate', 'Pending Proposal', 'Approval']  },
        { type: "select", values: [ 'Identify Proposal', 'Define Proposal',  'Evaluate', 'Pending Proposal', 'Approval']  },
        { type: "text" },
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null
    ]
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM