Closed l47y closed 10 months ago
Hello @l47y,
This is more than likely due to an issue with your value*
, you should be testing to see if there is a value
in the params first:
params.value ? valuegetterfunction : null
Something like the above should work. 😄
Hey @BSd3v - thanks a lot for your quick answer. Could you point me to the line in my code where I have to insert your suggested test? Sorry, my JavaScript understanding at this point is very basic :-)
Sure:
"valueGetter": {"function": f"params.value ? {date_obj} : null"},
"valueFormatter": {"function": f"""params.value ? d3.timeFormat('%b %d, %Y')({date_obj}) : null"""},
@BSd3v awesome - that solved it. I had to slightly change it to:
"valueGetter": {"function": f"params.data ? {date_obj} : null"},
"valueFormatter": {"function": f"""params.data ? d3.timeFormat('%b %d, %Y')({date_obj}) : null"""},
so I used params.data
instead of params.value
. With your initial version, the date column was just shown with only blank values and no error appeared in the console.
So all solved now. Thanks a lot for your quick response and solution :-)
Hi,
first, thank you so much for making ag-grid available within the Dash framework. This elevated my apps to another level and I get very positive feedback from users.
Summary of problem
I have a dataframe with a date column
date
. I use avalueGetter
andvalueFormatter
as stated in the docs, and filtering/sorting works perfectly. I recently enabled the pivot mode (we have an enterprise license) and the app is structured as follows: I have two navlinks that show/hide two different views. In my minimal example, I have Tab1, Tab2 while Tab1 contains the AgGrid. When doing the following:Then my app jumps back to Tab2 and throws some errors in the JavaScript console. When going back to the AgGrid, nothing seems wrong, the table is just shown normally. When you don't navigate to Tab2 first, you wouldn't notice the problem by just looking to the app, but the same errors are shown in the console.
Root cause
When I don't use the
valueGetter
andvalueFormatter
, the problem doesn't happen. However, I couldn't figure out what exactly is wrong with my setup. I guess there is an event triggered when toggling the pivot mode, that is responsible for this behavior. In the Browser console, the error also refers to thedate
column.Asking for help
In my production app, there are many more tabs, and users switch back and forth a lot and do ad-hoc analyses using the pivot mode. My app feels a bit buggy, when every time the app jumps back to the last tab. I reduced my app to the necessary parts, please apologize that the setup might be a bit more complex. Below you can find the code and environment to reproduce the issue, and I attached a screenshot with the errors from the Browser console. Huge thanks for taking a look.
Environment
python 3.9.6
with:App
Browser console error
I am using Chrome 119.0.6045.123