I have the following situation. I have a modal dialog with buttons. Each button opens and fill a accordion region with content. And i have a close button for the modal dialog which close the modal dialog and should clean up any accordion regions content by setting it to None. The goal: I want as less network transfer as possible. At the moment i have a callback which has the State of every accordion region and put them to the Output. This has a high network tranfer with more and more accordion buttons i open. I think i can solve this with pattern match callbacks. But the problem seems to be the close button because it needs all the accordions region as outputs to clean them. I found this topic: Pattern-matching callbacks: can you combine MATCH and ALL? to combine match and Alll but i think its not what i need. So my question is: How can i have a pattern match callback which has only the specific button id as input and the specific accorion region as output but all accordion outputs when i press close button ?
Example How the callbacks are implemented now without cleaning the accordion Content by clicking close button:
@app.callback(
[Output("modalHeader", 'children'),
Output('modal', 'is_open')],
[Input("dataTable", 'active_cell'),
Input("close", "n_clicks")],
[State("index", 'children'),
State("modal", "is_open"),
State("currentSite", "data"),
]
)
def openModal(table,close,index,is_open,currentSite):
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
objId = ''
if ctx.trigger.component == 'dataTable':
objId = active_cell['row_id']
elif ctx.trigger.component == 'close':
pass
return objId, not modalOpen
@app.callback(
Output({'role': 'accordionContent', 'index': MATCH}, 'children'),
Output({'role': 'accordionCollapse', 'index': MATCH}, 'is_open'),
Input({'role': 'accordionButton', 'index': MATCH}, "n_clicks"),
[State({'role': 'accordionContent', 'index': MATCH}, 'children'),
State({'role': 'accordionCollapse', 'index': MATCH}, 'is_open'),
State({'role': 'accordionButton', 'index': MATCH}, 'children'),
State('output', 'children'),State('currentSite', 'data'),
State('modalHeader', 'children')])
def triggerAccordion(n_clicks, content,is_open, buttonName, table, index, currentID):
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
if content is None:
content = calculateContent(buttonName, table, currentID)
return content, not is_open