My DataGrid is defined with
Data="@activeSessions" and after pressing the Delete button I can confirm that the correct row is removed from the
activeSessions variable, but that change is not reflected in the DataGrid view. I have tried both with and without calling
StateHasChanged() but I see no difference.
Does anyone have any input that can point me in the right direction?
I did not get the same problem there. Instead, turns out I didn't fully understand how the updating of the page worked.
Basically, the problem was that I fetched the data from a database and stored it in a variable
myData. But I wanted to do some filtering on that before displaying it, so I transformed the data and stored it another variable
activeSessions which was used in the DataGrid. However I didn't do the filtering/transformation in
OnInitializedAsync when I fetched the data, but in the razor code just before I declared the DataGrid. So even though the removed row was deleted from
activeSessions, it was immediately replaced with the original data in
myData... Stupid me... :P
Anyway, thanks for the (rubberducking) help!
Thanks @stsrki !
I actually ran into another thing now. Haven't had time to go through everything in detail, so excuse me if there's a simple solution I just havent found yet...
Once again concerning DataGrid, I would need different implementations for
OnRowUpdating (which, from what I can see, do not exist separately and only share an implementation in
OnRowSaving). What I want to achieve is:
Since both inserts and updates share their cancellable callback with
OnRowSaving (where I do the insertion's if-id-exists-then-cancel logic), the update is of course also cancelled since the ID already exists. Is there a way of discerning between updates/inserts in some way that I haven't found yet, or would I need some sort of workaround?