❔ Blazor Cascading Parameter with Async Change Event
Hi! I have a working cascading parameter, where the child component has a CascadingParameter property. It works just fine, when the parent changes the value, the value is propagated to the child.
The difficulty I'm having is that I want the child component to do some async server work when that value changes. Think of it as a cascading drop down - the parent has a drop down, and when a value is selected, the child component needs to go to the server to get data to fill a child drop down. I'm just not sure how to do that. The child component obviously has a get/set event on the cascading value, but I don't think you can do an async call from the set event.
I've tried to do some googling, but everything I find talks about how to propagate values up the chain via EventCallback, which is the reverse of what I need to do. Thank you for your help!
7 Replies
I can post some code if you need. Wasn't sure if it was needed, since it's not really a matter of doing something wrong or getting an error message; I'm just not sure how to do it 😄
you can call the method to get data in the parent component, and pass down the data to the child component. Or is it a strict requirement to do it that way?
Nah, no requirement. I guess I'm not familiar with how to call methods on child components. Trying to do some googling on it
you would have your onclick or ondata change or whatever on your parent component, then fire that and get data and pass it
or if your combobox is in your child component, you can pass a delagate from parent to child too
Ah, this is probably the best options. Thanks!
I'm a solo developer, so it's really easy for my head to start random walks in completely the wrong direction. Helps to have another set of eyes to just say, "hey, why not do this?"
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.