私は質問のために簡単なテストケースを用意しました。jQuery DataTables:チェックボックスをクリックするとDOM行をフィルタリングする方法は?
ディスクに保存してブラウザで開くだけですぐに動作しますので、何もダウンロードしたりインストールしたりする必要はありません。ここで
は私のテストケースのためのスクリーンショットです:
私の質問がされていますユーザーは果物および/またはキャンディーを選択したときにどのように私は、テーブル内の行をフィルタリングすることができますか?ここで呼び出す関数fnDraw()は何ですか?
私のテストファイルindex.htmlを:
<html>
<head>
<style type="text/css" title="currentStyle">
@import "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/redmond/jquery-ui.css";
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://raw.github.com/DataTables/DataTables/master/media/js/jquery.dataTables.js"></script>
<script type="text/javascript">
$(function() {
var my_table = $('#my_table').dataTable({
bJQueryUI: true,
aoColumns: [
/* type */ { bVisible: false, bSearchable: false },
/* thing */ null
]
});
$(':checkbox').click(function() {
alert('XXX what to do here? XXX');
});
});
</script>
</head>
<body>
<p>What should be shown:</p>
<p><label><input type="checkbox" value="fruit">fruit</label></p>
<p><label><input type="checkbox" value="candy">candy</label></p>
<table id="my_table">
<thead>
<tr>
<th>Type</th>
<th>Thing</th>
</tr>
</thead>
<tbody>
<tr><td>fruit</td><td>apple</td></tr>
<tr><td>fruit</td><td>banana</td></tr>
<tr><td>fruit</td><td>pear</td></tr>
<tr><td>candy</td><td>jelly</td></tr>
<tr><td>candy</td><td>toffee</td></tr>
<tr><td>candy</td><td>fudge</td></tr>
</tbody>
</table>
</body>
</html>
は、任意のヒントをありがとう!
更新:私はthe DataTables forumでも尋ねました。
は、私は例を挙げて取り組んでいると多分私はより良いhttp://www.datatables.net/release-datatables/examples/plug-ins/range_filteringのように$ .fn.dataTableExt.afnFilteringを使用する、ありがとう.htmlを呼び出してfnDraw()を呼び出すと、 –