layui的table我选中了4行,怎么把这4行的一列数据(id)获取并传到后台呢?
目前我只能获取选中1行的数据,获取不了多行,请大佬赐教~
var orgIdArr = [];
table.on('checkbox(test)', function(obj){
var checked = obj.checked;
var id= obj.data.id;
var type = obj.type; // all/one
if (type == "all") {
orgIdArr.push(checked);
orgIdArr.push(type);
} else {
if (checked) {
orgIdArr.push(id);
} else {
orgIdArr.remove(id);
}
}
orgIds = orgIdArr.join(",");
console.log(orgIds);
});
// 根据数组元素下表删除指定元素
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};