Please help me understand timing of updates to the style for itemtab...
description of function i want:
the functionality I want is to change the color or icon or anything about the currently displayed tab.
in this case, i have list of staff and when at least one staff is marked as excluded, then i want to highlight that tab as having someone excluded...
what i did:
i have the style attribute linked o the source data.
If the condition is true on the data, i change the style and use invoke for statehaschanged.
when a change to the child component occurs it doesn't work on first change
...the style only seems to change after second change...and in effect it's like the change is using stale data, yet i can see the data displayed
however, if I change to different tab or just click the current tab, the style does update
i know that the data is changed, because i display it, so it shows the data...but the control didn't get the update!!!!!
I know you can create ref to control, i thought i might be able to dynamically refresh it, but no luck there.
Any ideas what i could do to insure the style of the RadzenTabItem gets refreshed when the child component data for the style is changed?
the picture is the parent component that is called by the child where the change to data occured...
and so yes, I know about that and have done due dilligence to make that happen and it does work for the data displayed....like i said originally, ..but the control of the parent does not refresh...and that is a Radzen control...
yes i have used @key but i was having issue as it needed to be unique and that little example you provided there is what i was looking for...testing...
i'm sorry, but your example is not a mirror of my example and so it's not a valid comparison.
i have a service with the two different datasets...SourceData and SourceStaff.
@foreach (var dept in ((MyService)myservice).SourceData) <--- for the tabs @foreach (var staff in ((MyService)myservice).SourceStaff.Where(a => a.dept == dept.dept)) <-- within each tab
for my custom control embedded inside the loop of staff...i pass both the sourcedata and sourcestaff data to the child control...
inside that control when the radzen checkbox is clicked...
Did you try setting the @key attribute? It is the key to making it work. Considering the code you have pasted so far you can use @dept.style (if it is unique) or the index of the tab otherwise ...
If neither of those work we will need to reproduce the issue locally somehow. You can either modify my example so I can run it locally or send us a runnable version of your project to info@radzen.com.
my understanding of @key is that the data it is related to must change for it to fire...
in this case the dept.dept is not changing, but data inside of that dataset is...
i thought i could use a special unique field for this purpose , in other words, create a field that when i change the data , i then update the column with a new value which in effect tells this to be rerendered...
and so using that isn't going to work as far as i know..
tried that and it almost worked....however, apparently the @key determines the order of the tabs.....
and so no matter what i associate it with that changes, when i make a change, the tab is rendered in different order now..and so i'm no longer on the right tab after clicking...no worky. sorry.
We just released a new version of Radzen.Blazor (2.15.12) which should handle this issue automatically. This means that if you upgrade your code should just work without using @key or manually invoking the newly introduced Reload method of the RadzenTabs component. You should keep the existing code of the RefreshMe method which invokes StateHasChanged of the page.