[英]How to load different options in AG-Grid select dropdown ,based on other cell value in the same row with Angular 6?
I am using the following code in the Column Definition : 我在“ 列定义”中使用以下代码:
{ headerName: 'Part', field: 'part',
cellStyle: {'background-color': 'cyan'}, editable: true,
cellEditor:'agSelectCellEditor', cellEditorParams:
I have other column in the grid ex- 我在表格前还有其他专栏
{ headerName: 'Colour', field: 'colour',
cellStyle: {'background-color': 'cyan'}, editable: true,
cellEditor:'agSelectCellEditor', cellEditorParams: function(params) {
var selectedPart = params.data.type; if (selectedPart==='R&S') {
return { values: this.partTypeListRS }; } else if(selectedPart==='WiFi')
{ return { values: this.partTypeListWifi }; } else
if(selectedPart==='Other') { return { values: this.partTypeListOther };
}}},
}
I am getting the error cannot read property this.partTypeListRS of undefined ,if I click on a row where selectedPart==='R&S' condition is satisfied and respectively for all the other conditions . 如果我单击满足selectedPart ==='R&S'条件并分别满足所有其他条件的行,则会收到无法读取未定义的属性this.partTypeListRS的错误。
You can define your cellEditorParams
function in a way that returns different values depending on values of another column. 您可以定义cellEditorParams
函数,以根据另一列的值返回不同的值。
Here is a sample from the ag-grid site - 这是来自ag-grid网站的示例-
cellEditor : 'agSelectCellEditor';
cellEditorParams: function(params) {
var selectedCountry = params.data.country;
if (selectedCountry==='Ireland') {
return {
values: ['Dublin','Cork','Galway']
};
} else {
return {
values: ['New York','Los Angeles','Chicago','Houston']
};
}
}
Take a look at this example from official docs. 看一下官方文档中的这个例子 。
而不是function(params)
,我使用了箭头函数(params)=>
,然后我可以在CellEditorParams内部访问它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.