I am having trouble extracting the data-type from an AgGrid column dynamically. in my case, the AgGrid starts with no data (i.e: rowData = []
), meaning I can’t just iterate over rowData
and extract the type
of the value stored at any field, and I populate the data with a callback to rowTransaction
from a button click (essentially, add rows when a user specifies). Additionally, my AgGrid is a subcomponent of a custom AIO (All-in-One) component because I want to re-use the grid in different places in my app and re-use the callbacks as I don’t want to re-write them for every similar grid I create; i.e: the layout of my grid doesn’t change (i.e: it’s placement in a div with a few other buttons and multi-selects remains the same) and the interactivity (callbacks) the grid has with other subcomponents (like buttons and multi-selects) remains the same, but the data/rows I am trying to display will change (hence, why I thought an AIO would be appropriate).
In javascript (see here ), one can define cell-datatypes (and I can see how this would be easy to map to a python data type (i.e: “text → str()”, and "number → int/float etc…), but there doesn’t seem to be an analog in the Dash AgGrid component properties. I found that in columnDefs
there is a property called type
, but that doesn’t appear to be useful information (or straight forward to derive the data type of a cell or column dynamically).
Additionally, I tried passing additional context in the AIO components class constructor:
def __init__(self, row_format, AgGrid_props=None, button_props=None, <remaining_subcomponents_props>=None)
where, row_format = {"field1":str, "field2":int}
is the information I want to utilize, but I seem to be not able to pass class properties to callbacks, as the @callback
decorator dictates the outputs and inputs of the callback, and an error is thrown if I pass self
to the callback.
What is the best way to go about fixing this issue?