jeudi 30 janvier 2020

Uncheck Checkbox when i use display "none" on some rows

Hei guys, I am trying to change my Check All Button to only check the rows that are visible. Unfortunately i am not seeing how i can address just the visible rows. I tried something like this, but i didnt work out.

$("#checkAll").click(function(){
    if(!x){
        if($(".check").is("visible")){
        $(':checkbox').each(function(){ this.checked = true; 

        });}

        x=true;}

    else{
        $(':checkbox').each(function(){ this.checked = false; });
        x= false;
        }});

Thats how i filter my table.

function abtFilter() {
      // Declare variables
      var input, filter, table, tr, td, i, txtValue;
      input = document.getElementById("searchbar");
      filter = input.value.toUpperCase();
      table = document.getElementById("notfallTable");
      tr = table.getElementsByTagName("tr");
      // Loop through all table rows, and hide those who don't match the search query
      for (i = 0; i < tr.length; i++) {
        td = tr[i].getElementsByTagName("td")[3];
        if (td) {
          txtValue = td.textContent || td.innerText;
          if (txtValue.toUpperCase().indexOf(filter) > -1) {
            tr[i].style.display = "";
          } else {
            tr[i].style.display = "none";
            $("")
          }
        }
      }
    }

and this is how the table looks like.

        items.push("<td class='numbers' contenteditable>"+val.Nummer+"</td>");
        items.push("<td contenteditable>"+val.Typ+"</td>");
        items.push("<td contenteditable>"+val.Vorname+"</td>");
        items.push("<td contenteditable>"+val.Nachname+"</td>");
        items.push("<td contenteditable>"+val.Abteilung+"</td>");

        items.push("<td class='check'><label><input type='checkbox'>"+""+"</input></label></td>");

        items.push("</tr>");

Greetings Elfdow




Aucun commentaire:

Enregistrer un commentaire