Editable DataTable with dropdown in cells plus user input that differs from dropdown

Hey all,

I was planning on creating a datatable that lets user insert data in the cells. Over time, the program will save all inserted data and provide a dropdownlist in the cells, so the user would be able to either choose from the dropdown or type his input AND the user has to be able to be insert values that are not in the dropdownlist. That is the part I am struggling with.
I tried to create a reproducable code. It differs a little from my implementation so far, but it shows the problem anyways. This would be the code:

from dash import html, Output, Input, State, Dash
from dash.dash_table import DataTable

def set_children():
    options = {'Column1': ["Value1"], 'Column3': ["Value1"]}
    return [
            {'name': 'Col1', 'id': 'Column1', 'editable': True, "presentation": "dropdown"},
            {'name': 'Col2', 'id': 'Column2', 'editable': True},
            {'name': 'Col3', 'id': 'Column3', 'editable': True, "presentation": "dropdown"},
            {'Column1': '', 'Column2': '1', 'Column3': ''}
            'Column1': {
                'options': [{'label': i, 'value': i}
                            for i in options["Column1"]],
            'Column3': {
                'options': [{'label': i, 'value': i}
                            for i in options["Column3"]],
    # Button to add new row
    html.Button("new_row", id="add-row-button")

app = Dash()
app.layout = html.Div(id="main_div", children=set_children())

#Callback to add new row
    Output('editable-table', 'data'),
    [Input('add-row-button', 'n_clicks')],
    [State('editable-table', 'data')],
def add_row(n_clicks, current_data):
    if n_clicks:
        current_data.append({'Column1': '', 'Column2': '1', 'Column3': ''})
    return current_data


The idea would be that the options variable expands with new user input, but at the moment the program only lets me insert values that are already in the options dictionary (here it would be “Value1”) If I enter something else the dropdown only shows something like “no result” and the moment I exit the cell, it resets to an empty cell. It would be great if you could help me.
Thanks in advance!

Hi @mrchlnglo

This feature isn’t available in DataTable, but you can do this with a dmc.Select custom component in a cell of Dash AG Grid. You can find an example here:

1 Like

Hi @AnnMarieW
Thank you for your fast answer. I tried running the Code from the link in your linked answer (dash-ag-grid/docs/examples/components/cell_editor_dmc_select.py at main · plotly/dash-ag-grid · GitHub). It runs with no error, but I do not get any dropdown options like you in your demo video from the linked post. I have trouble finding the dashAgFunctions.js file which has to be edited? In the code it states that I need to “Add this to the dashAgGridFunctions.js file in the assets folder” but I do not see an assets folder and can’t find any file named dashAgGridFunctions.js. I am working in PyCharm Community edition. In lib > python3.11 > site-packages, I could find a “dasAgGrid” folder but that only contains three .js files: async-community, async-enterprise and dash_ag_grid.min
Could you help me find the place where I have to change something to make it work.
This is how it looks when I run the code and try to edit a cell:

Hi @mrchlnglo

You need to create a folder called assets in the same place as your app, then add the dashAgGridFunctions.js file to the assets folder.

For more information, see the dash docs:

For more information on using Cell Renderer components in Dash AG Grid see:


Thank you for your help. I could implement the solution and assets folder :slight_smile: