Cell Editors

A cell editor component is the UI that appears, normally inside a cell, that takes care of the edit operation.
You can select from the Column Definitions or
create your own Column Definitions.

Cell Editor Components are configured using the cellEditor property of
the

Dynamic Parameters

Parameters for cell editors can be dynamic to allow different selections based on what cell is being edited. For
example, you might have a ‘City’ column that has values based on the ‘Country’ column. To do this, provide a function
that returns parameters for the property cellEditorParams.

View the JavaScript function used for this example.

This JavaScript function must be added to the dashAgGridFunctions.js file in the assets folder.
See JavaScript Functions
for more information.

var dagfuncs = (window.dashAgGridFunctions = window.dashAgGridFunctions || {});

dagfuncs.dynamicOptions = function (params) {
    const selectedCountry = params.data.country;
    if (selectedCountry === "United States") {
        return {
            values: ["Boston", "Chicago", "San Francisco"],
        };
    } else {
        return {
            values: ["Montreal", "Vancouver", "Calgary"],
        };
    }
};

Custom Datepicker Cell Editing

The example below demonstrates how to use a custom date picker as a cell editor. The ‘Date’ column uses a component
cell editor that allows you to pick a date using jQuery UI Datepicker.

View the JavaScript class used for this example.

This JavaScript class must be added to the dashAgGridFunctions.js file in the assets folder.
See JavaScript Functions
for more information.

var dagfuncs = (window.dashAgGridFunctions = window.dashAgGridFunctions || {});

dagfuncs.DatePicker = class {
    // gets called once before the renderer is used
    init(params) {
        // create the cell
        this.eInput = document.createElement("input");
        this.eInput.value = params.value;
        this.eInput.classList.add("ag-input");
        this.eInput.style.height = "var(--ag-row-height)";
        this.eInput.style.fontSize = "calc(var(--ag-font-size) + 1px)";

        // <a href="https://jqueryui.com/datepicker/">https://jqueryui.com/datepicker/</a>
        $(this.eInput).datepicker({
            dateFormat: "dd/mm/yy",
            onSelect: () => {
                this.eInput.focus();
            },
        });
    }

    // gets called once when grid ready to insert the element
    getGui() {
        return this.eInput;
    }

    // focus and select can be done after the gui is attached
    afterGuiAttached() {
        this.eInput.focus();
        this.eInput.select();
    }

    // any cleanup we need to be done here
    destroy() {
        // but this example is simple, no cleanup, we could
        // even leave this method out as it's optional
    }

    // if true, then this editor will appear in a popup
    isPopup() {
        // and we could leave this method out also, false is the default
        return false;
    }
};

Custom date picker