首页 > 代码库 > 遍历表格中的数据,将表格中的某行的某个字段存到数组中,且该数组中不能有相同字段值

遍历表格中的数据,将表格中的某行的某个字段存到数组中,且该数组中不能有相同字段值

var ishas = false;

var pid_arr= [];      

onLoadSuccess: function (data) {
       
            if (data.length > 0) {
                for (var i = 0; i < data.length; i++) {
                    if (pid_arr.length == 0) {
                        pid_arr.push(data[i].pid);
                    } else {
                        ishas = false;
                        for (var j = 0; j < pid_arr.length; j++) {
                            if ((pid_arr[j] == data[i].pid) ) {
                                ishas = true;
                            }
                        }
                        if (!ishas && (data[i].pid != null)) {
                            pid_arr.push(data[i].pid);
                        }
                    }

                }
            }
            console.info(pid_arr);
        }

遍历表格中的数据,将表格中的某行的某个字段存到数组中,且该数组中不能有相同字段值