我有基于 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 来获取。