table.search(this.value).draw(); not working
table.search(this.value).draw(); not working
phieutr
Posts: 2Questions: 1Answers: 0
I am trying to filter table by available condition, I use onclick event to load data, everything is fine but finally filter is not working, database is still searching but nothing happens with my html i am a newbie and never had this case before.
<input type="submit" class="m-0" style="color:#05d34e!important " id="statusgroup_0" name="statusgroup_0" value="statusgroup_0"></input>
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Tên Team</th>
<th scope="col">Ngày thành lập</th>
<th scope="col">Admin</th>
<th scope="col">Thành viên nhóm</th>
<th scope="col">Trạng thái</th>
<th scope="col">Ghi chú</th>
</tr>
</thead>
<tbody>
<tr class="group_item odd" value="statusgroup_0" role="row">
<th scope="row" tabindex="0" class="sorting_1"> <a href="#" class="question_content">19</a></th>
<td>Nhóm 1</td>
<td>2022-11-10 11:13:11</td>
<td>Xuân phiêu</td>
<td><ul style="display: flex;"></td>
<td><a href="#" class="status_btn statusgroup_0">Hoạt động</a></td>
<td><p>marketing</p></td>
</tr><tr class="group_item even" value="statusgroup_1" role="row">
<th scope="row" tabindex="0" class="sorting_1"> <a href="#" class="question_content">20</a></th>
<td>Nhóm 2</td>
<td>2022-11-10 11:14:21</td>
<td>Xuân phiêu</td>
<td><ul style="display: flex;"></td>
<td><a href="#" class="danger_btn statusgroup_1">Tạm dừng</a></td>
<td><p>Dev</p></td>
</tr><tr class="group_item odd" value="statusgroup_0" role="row">
<th scope="row" tabindex="0" class="sorting_1"> <a href="#" class="question_content">21</a></th>
<td>Nhóm 3</td>
<td>2022-11-10 15:25:27</td>
<td>Xuân phiêu</td>
<td><ul style="display: flex;"></td>
<td><a href="#" class="status_btn statusgroup_0">Hoạt động</a></td>
<td><p>fontend</p></td>
</tr></tbody>
</table>
//javascript
$(document).ready(function() {
var table = $('#table-statusgroup').DataTable();
// console.log(table)
$('#statusgroup_0').on('click', function () {
// console.log(this.value)
table.search(this.value).draw();
} );
});
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Replies
Without a running test case showing the issue its ahrd to say what the problem might e. First step is to make sure the click event is working. You have a commented out console log statement. If uncommented does it show on the console? What is
this.value
?If you still need help please post a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin