Hello devs.
I am stuck with my code and idk how to circunvent a problem I have when not all Outputs contain the MATCH.
My problem is as follows:
The HTML structure is something like this:
SessionStore_A
SessionStore_B
Main
Parent
Child_1
Input_A
Input_B
Input_C
Basically what I want is:
- Select
Input_A - Make options for
Input_BandC(based onA) - Make
Child_2with same content asChild_1
My code is as follows:
import get_options from package
@callback(
Output('Parent', 'children'),
Output({'type':'Input_B', 'index':MATCH}, 'options'),
Output({'type':'Input_C', 'index':MATCH}, 'options'),
Output('SessionStorage_A', 'data'),
Output('SessionStorage_B', 'data'),
Input({'type':'Input_A', 'index':MATCH}, 'value'),
State({'type':'Input_B', 'index':MATCH}, 'options'),
State({'type':'Input_C', 'index':MATCH}, 'options'),
State('parent', 'children'),
State('SessionStorage_A', 'data'),
State('SessionStorage_B', 'data'),
)
def process(Input_A_value,
current_A_options, current_B_options,
current_childrens,
SessionStoraga_A_data, SessionStorage_B_data):
if not is_valid(Input_A_value):
return (current_A_options, current_B_options,
current_childrens,
SessionStorage_A_data, SessionStorage_B_data)
SessionStorage_B_data['SelectedVal'] = Input_A_value # Just to store the selections in case of reload.
A,B = get_options(Input_A_value)
SessionStorage_A_data['GotValues'] = A,B # It is basically to memoize but at client level.
ParentChildrensPatch = Patch()
next_child = make_next_child()
ParentChildrensPatch.append(next_child)
return (ParentChildrensPatch,
A, B,
SessionStorage_A_data, SessionStorage_B_data)
With this I get the errors:
Mismatched `MATCH` wildcards across `Output`s
`Input` / `State` wildcards not in `Output`s
Which I have seen it is because they all need to have the MATCH wildcard and I have seen solutions using ALL and figuring out the inputs using ctx.
I know how to use ctx, i just don’t know how to partially update the options.
Also, I have thought of just updating SessionStorage_B and rebulding the page each time based on that. Hadn’t tested but feels inefficient.
Thanks in advance.