js删除json数组中指定数组
js删除json数组中指定数组
var dataTree = eval(${tree!"null"});
var su_type = '${su_type!"null"}';
var deleteData =[
{"id":"42BFB41416FB487CA41419C08C21E271","text":"xxx","attributes":{"wc_parentid":"0"}},
{"id":"4614927F779D4A0A965FABD5F301AD66","text":"xxxxx","attributes":{"wc_parentid":"0"}},
{"id":"A722289D74D74155B797B79931346437","text":"xxxxxxx","attributes":{"wc_parentid":"0"}},
{"id":"D83296DD47754F6087D3C9EE0A0B365A","text":"xxxxxxx","attributes":{"wc_parentid":"0"}}
];
/*
* 删除json数组中指定数组
* */
function checkWc(dataTree, su_type, temp) {
if (su_type == '3') {
for (var i = 0; i < dataTree.length; i++) {
var itemWc = dataTree[i];
for (var k = 0; k < temp.length; k++) {//遍历外部数组
var tempDetail = temp[k];
for (var j = 0; j < itemWc.children.length; j++) {//遍历待删除数组
var itemDetail = itemWc.children[j];
if (itemDetail.id === tempDetail.id) {
dataTree[i].children.remove(dataTree[i].children[j]);
} else if (itemDetail.id === tempDetail.id) {
dataTree[i].children.remove(dataTree[i].children[j]);
} else if (itemDetail.id === tempDetail.id) {
dataTree[i].children.remove(dataTree[i].children[j]);
} else if (itemDetail.id === tempDetail.id) {
dataTree[i].children.remove(dataTree[i].children[j]);
}
}
}
}
return dataTree;
} else {
return dataTree;
}
}
更多推荐
所有评论(0)