LayUI Table check box gets selected data

Method 1 Click the check box to collect or remove the number 
//The following are related operations of the check box 
table.on('checkbox(container)', function (obj) { 
        if (obj.checked) { 
            //obj.type If the trigger is all selected, it is: all, if the trigger is single selection, then if ( 
            obj.type === "one") { 
                mns.push(obj.data.stacode); 
            } else { 
                var datas = table.getData ("table") // eg let data = table.getData('Table-List'); $.each(datas, function (idx, item) { mns.push(item.stacode); }); } } else { if (obj.type 
                === 
                    " 
                one 
            " 
        ) 
            { 
                //Get the subscript of cc in the array
                var index = jQuery.inArray(obj.data.stacode, mns);
                //Delete from the index element in the array, the deleted length is 1 
                mns.splice(index, 1); 
            } else { 
                mns = []; 
            } 
        } 
        console.log(mns.join(",")); 
    } 
);

Method 2 Unified collection

var datas = table.checkStatus("table").data;
$.each(datas, function (idx, item) {
    if (item.online) {
        mns.push(item.stacode);
    }
});
 

Guess you like

Origin blog.csdn.net/zkcharge/article/details/130741085