Skip to content

getRowStyle not working through JavaScript functions in asset file #364

@OttoJHTX

Description

@OttoJHTX

When using a JavaScript function in getRowStyle, it will not be called, even though it is defined in an asset file.

Sample code:
app.py

import dash_ag_grid as dag
from dash import Dash, html

app = Dash()

rowData = [
    {"employee": "Josh Finch", "sickDays": 4},
    {"employee": "Flavia Mccloskey", "sickDays": 1},
    {"employee": "Marine Creason", "sickDays": 8},
]

columnDefs = [
    {"headerName": "Employee", "field": "employee",},
    {"headerName": "Number Sick Days", "field": "sickDays"},
]

getRowStyle = {
    "function": "rowStyleFunction(params)",
}

app.layout = html.Div(
    [
        dag.AgGrid(
            id="styling-rows-conditional-style2",
            columnDefs=columnDefs,
            rowData=rowData,
            columnSize="sizeToFit",
            getRowStyle=getRowStyle,
            dashGridOptions={"animateRows": False},
        ),
    ],
)

if __name__ == "__main__":
    app.run(debug=True)

assets/functions.js

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

dagfuncs.rowStyleFunction = function (params) {
  console.log("rowStyleFunction called");
  return { backgroundColor: "blue", color: "white" };
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions