有条件地显示数据

时间:2018-01-16 13:00:24

标签: javascript angular

我有一个结构,我需要根据一些条件显示数据:

假设我有 EmployeeId,EmployeeName,CompanyName和...作为键。如果我选择employeeName然后所有EmployeeName将被列入表中,那么如果我选择EmployeeId,它应该列出与EmployeeName相关的EmployeeId ..如:

docs 这就像我试图获得像excel

的数据透视表这样的功能

我试过从jsonfile获取数据,然后存储它并创建json对象,但问题是我没有得到相应的关系数据..

createJSON(e:any,attributeData) {
    this.count++;
    this.jsonObj = [];
    for(var i = 0; i < this.pivotItems.length; i++) {
        var item = {};
        for(var j = 0; j < attributeData.length; j++) {
            item [attributeData[j]] = [this.pivotItems[i][attributeData[j]]];
            if( this.jsonObj.indexOf(item) == -1) {
                this.jsonObj.push(item);
            }
        }
    }
    // item [e.dragData] = e.dragData;
    //this.jsonObj.push(item);
    //this.relatedData();
    console.log(this.jsonObj);
}

0 个答案:

没有答案