mardi 17 janvier 2017

jQuery Datatables update inputs on checkbox change

So I'm using jQuery Datatables to generate a table. This table is used to order products, now I need to make a checkbox to update all the rows in the table but with a condition.

This is a row out of the table (name,instock,stockmin,stockmax,order) Table example

So upon checking the checkbox it should check

if($instock < $stockmin)

if that returns true, it should update the input by $stockmin - $instock

This is what I have so far.

$.fn.dataTableExt.afnFiltering.push(function (oSettings, aData, iDataIndex) {
            var checked = $('#lowstock').is(':checked');
            if (checked && (aData[2] < aData[3])) {
                return true;
            }

            if (!checked) {
                return true;
            }
            return false;
        });

This works, it filters the right rows but the question is how to target that row and update its input.

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire