如何将搜索范围输入添加到数据表中

时间:2017-12-05 14:20:00

标签: angularjs angular-datatables

<span>Product:</span>
<input type="text" name="product" class="form-control input-sm">
<span>Code:</span>
<input type="text" name="code" class="form-control input-sm">
**<span>Min Price:</span>
<input type="text" name="price" class="form-control input-sm">**

如何搜索输入中的价格范围,如0-100 100-500 500-1000或使用选择。

$(document).ready(function() { 
  // Map inputs with columns (nth-child(X)) 
  var inputMapper = {
    "product": 1,
    "code": 2,
    "price": 3
  };
  $("input").on("input", function() {
    var $this = $(this);
    var val = $this.val();
    var key = $this.attr("name");
    dtInstance.columns(inputMapper[key] - 1).search(val).draw();
  });
});

0 个答案:

没有答案