繁体   English   中英

jQuery DataTable列过滤器-选择下拉过滤器

[英]JQuery DataTable Column Filter - select dropdown filter

目前,我正在尝试使用一个下拉列表来过滤我的表(我正在使用Datatable插件)

这是我的代码:

         $('#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
]
});
      }); 

我想做的是让我的表有一个下拉过滤器: http : //jquery-datatables-column-filter.googlecode.com/svn/trunk/customFilters.html

但是由于某些原因,它没有做应做的事情。 我不知道我做错了什么。 这是到我的桌子的链接: http : //176.32.230.19/caffeine-cranked.com/Files/test.html

也许您必须为每列添加一种过滤器(总计13个)。 像这样:

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
    ]
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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