本文介绍了agSelectCellEditor动态列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ag-grid,对于任何给定的行,我希望一列中的下拉列表取决于另一列的值。我可以使用agSelectCellEditor来做到这一点,还是必须创建一个自定义组件。

I am using ag-grid and for any given row I would like the dropdown in one column to be dependent on the value of a different column. Can I do that with agSelectCellEditor or do I have to create a custom component.

推荐答案

您可以定义 cellEditorParams 函数可以根据另一列的值返回不同的值。

You can define your cellEditorParams function in a way that returns different values depending on values of another column.

以下是来自ag-grid网站的示例-

Here is a sample from the ag-grid site -

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']
        };
    }
}

看看这个来自官方文档。您必须将 agRichSelectCellEditor 替换为 agSelectCellEditor

Take a look at this example from official docs. You will have to replace agRichSelectCellEditor with agSelectCellEditor

这篇关于agSelectCellEditor动态列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 03:15