Hi, I have read through the forums on how to style the datatable export button. Basically, this solution by @Higgcz seems to be the most convenient but uses javascript python based on what i understand. I can hide the button,
in mypage.py:
export_csv_button = dbc.Button(
"Export to csv",
id='mybutton',
n_clicks=0,
)
in index.py:
app.clientside_callback(
"""
function(n_clicks) {
if (n_clicks > 0)
document.querySelector("#datatable button.export").click()
return ""
}
""",
Output("mybutton", "dummy-data"),
[Input("mybutton", "n_clicks")]
)
My issues is that sometimes, i come across this error: Cannot read property ‘dummy-data’ of undefined.
For one, i never actually define dummy-data anywhere besides in the output, so this error makes sense. But on the other hand, this solution does work sometimes?? So im really confused. I’m also not sure how the js callbacks really work, is it possible to do a python version of the code?
Based on what i’ve seen regarding this error, it seems that we are querying before the user has clicked on the button? If that’s the case, how do i fix this in js code? Because the solution here is for python callbacks.
Hope this question can be answered soon.