0

我有基于 ag-grid 覆盖范围的应用程序,其中richSelect 下拉列表用于某些列。对于某些richSelect 列,下拉列表中的值应基于id。

我的 JSON 数据如下所示:

data : [{
        collegeId : "MIT",
        users : [{
                name : "Alex",
                country : "USA"
            }, {
                name : "Barbara",
                country : "Canada"
            }
        ]
    }, {
        collegeId : "Berkeley",
        users : [{
                name : "Samantha",
                country : "Australia"
            }, {
                name : "Amanda",
                country : "Germany"
            }
        ]
    }
]

这是我的 colDefs 的样子:

{ headerName : "Users", field: "users", filter: "text", 
    cellEditor : "richSelect",
    cellEditorParams : {
        values : this.getValues()
    }
}

问题是,在麻省理工学院的行中,我希望用户列表中只有 Alex 和 Barbara。同样对于伯克利,我需要用户的richSelect 只有萨曼莎和阿曼达。

这里用户列表取决于collegeId。在 getValues() 中,我可以获取所有用户,但不知道如何根据匹配的学院 ID 来获取。

4

1 回答 1

0

您可以如下更新值 -

这里创建了 $scope.newMap 地图,使用键、值添加要在地图中显示的值并分配给 cellEditorParams

 for(var x=0;x<$scope.gridOptions.columnDefs.length;x++){
            if($scope.gridOptions.columnDefs[x].headerName==="Bank Name"){
                $scope.gridOptions.columnDefs[x].cellEditorParams.values=$scope.newMap;
            }
        }
于 2017-01-04T07:56:05.797 回答