2017-02-01 47 views
0

我必須根據特定列的值過濾表中的數據。 這是我的表 Table with data to be filtered如何使用jquery過濾按鈕單擊表中的數據

我要篩選最後一欄「狀態」,這顯示了學生是否被驗證與否的基礎上,此表。我必須在按鈕的點擊事件上做到這一點。 這是我的按鈕

enter image description here

我想,當我點擊這個「驗證學生」按鈕,該表只顯示驗證學生名單和隱藏未經證實的學生。 我有點困惑,請幫忙。

<table id="Skilllist" class="table table-striped table-bordered "> 
 
    <thead class="text-center"> 
 
    <tr> 
 
     <th> 
 
     <input type="checkbox" class="allchk1" id="allchk" /> 
 
     </th> 
 
     <th>S.NO.</th> 
 
     <th>CAMPUS</th> 
 
     <th>ROLL NO.</th> 
 
     <th>NAME</th> 
 
     <th>Gender</th> 
 
     <th>EMAIL ID</th> 
 
     <th>CGPA</th> 
 
     <th>PS Type</th> 
 
     <th>Batch</th> 
 
     <th>STATUS</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody id="Studentlistdata"> 
 
    </tbody> 
 
</table> 
 

 
<div style="display: none"> 
 
    <table> 
 
    <tbody> 
 
     <tr id="Studentlist1"> 
 
     <td> 
 
      <input type="checkbox" class="Allchk" chk="chk" id="Chek1" /> 
 
     </td> 
 
     <td id="Srno" class="ver unver"></td> 
 
     <td id="Campus" class="ver unver"></td> 
 
     <td id="RollNo" class="rollnumber ver unver"></td> 
 
     <td id="Name" class="ver unver"></td> 
 
     <td id="disc" class="ver unver"></td> 
 
     <td id="email" class="ver unver"></td> 
 
     <td id="Cgpa" class="ver unver"></td> 
 
     <td id="pstype" class="ver unver"></td> 
 
     <td id="batchname" class="ver unver"></td> 
 
     <td id="sta" class="ver unver"> 
 
      <label id="sta1" class="label label-default">Not Verified</label> 
 
     </td> 
 
     </tr> 
 
    </tbody> 
 
    </table> 
 
</div>

+0

做一個AJAX調用後端烏爾法和篩選結果,或使用jQuery數據表作爲一個變通。 –

+0

我試過這個,但沒有工作。 –

回答

1

您可以使用此方法將其過濾:

hide()所有trtbody瑤池(在演示案例中稱爲stud_body),下一個show()中的所有項其中包含指定的狀態,rows.filter(":contains('yourStatus')").show()

$("#searchButton").click(function() { 
    var rows = $("#stud_body").find("tr").hide(); 
    rows.filter(":contains('OK')").show(); 
}); 

演示:http://jsfiddle.net/w6mvoo7a/

+0

謝謝!!!!!有效 –

0

類添加到您的線路,當你創建列表。

<tr id="Studentlist1" class="ver"> //FOR VERIFIED 
<tr id="Studentlist1" class="nver"> //FOR NOT VERIFIED 

THEN 類添加到您的表像「秀驗證」使用jQuery當您單擊按鈕。

$("#clicked_buttonName").click(function() { 
    $(".yourTable").addClass("show-verified"); 
}); 

然後寫像

.show-verified .nver{display:hidden} 

一個CSS這將讓你的未驗證類隱形

相關問題