首页 新闻 会员 周边

layui如何获取table的选中多行数据

0
悬赏园豆:10 [已关闭问题] 关闭于 2019-10-17 15:00


layui的table我选中了4行,怎么把这4行的一列数据(id)获取并传到后台呢?
目前我只能获取选中1行的数据,获取不了多行,请大佬赐教~

CodePanda的主页 CodePanda | 初学一级 | 园豆:13
提问于:2019-10-17 10:47
< >
分享
所有回答(1)
0

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);
}
};

Kavyom | 园豆:202 (菜鸟二级) | 2020-06-13 13:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册