1

I have to filter data in my table on the basis of a particular column's value. This is my table Table with data to be filtered

And I want to filter this table on the basis of last column "STATUS" which shows whether a student is verified or not. And I have to do this on the click event of button. This is my button

enter image description here

I want when I click this "verified student" button, the table just show the list of verified students and hide the unverified students. I am a bit confused please help.

<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>

2
  • Do an ajax call to ur backend method and filter your results or use jquery datatable as a work around. Commented Feb 1, 2017 at 10:49
  • I have tried this but didn't work. Commented Feb 1, 2017 at 10:52

2 Answers 2

3

You can filter it using this method:

hide() all tr finded in tbody (in demo case called stud_body), next show() all items in rows which contains specified status, rows.filter(":contains('yourStatus')").show()

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

demo: http://jsfiddle.net/w6mvoo7a/

Sign up to request clarification or add additional context in comments.

Comments

1

add a class to your line when you creating the listing.

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

THEN add a class to your table like "show-verified" with jquery when you click the button.

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

THEN write a css like

.show-verified .nver{display:hidden}

It will makes your Not Verified classes invisible

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.