Tommie Jones
Tommie Jones

Reputation: 1011

agSelectCellEditor dynamic list

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.

Upvotes: 5

Views: 12795

Answers (1)

Pratik Bhat
Pratik Bhat

Reputation: 7614

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

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

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

Upvotes: 8

Related Questions