vendredi 28 août 2015

Uncheck table row in bootstrap table on specific condition

My previous question was this and I want to uncheck checked row if user selects a row that has 'Stock Available=null or 0'. Now my jquery code is:

$(document).ready(function()
{
    $("#add_cart_btn").hide();
    var json;
    var checkedRows = [];
    $('#table-style').on('check.bs.table', function (e, row) {
      checkedRows.push({id: row.id});
      $("#add_cart_btn").show();
    });

    $('#table-style').on('uncheck.bs.table', function (e, row) {
      $.each(checkedRows, function(index, value) {
        if (value.id === row.id) {
          checkedRows.splice(index,1);
        }
      });
    });
     /*if(checkedRows.length < 0) {
        // does not exist
        $("#add_cart_btn").hide();
      }
      else {
        // does exist
        $("#add_cart_btn").show();
      }*/

});

Here I'm also trying to show $("#add_cart_btn") button iff checkedRows[] contains at least one record. I searched bootstrap events for above but understood it.




Aucun commentaire:

Enregistrer un commentaire