I have a requirement to present a parent viewmodel that has a "Type" attribute, which when toggled, should display one of 2 different sets of viewmodels. I have managed to add 2 separate collections, both with template add row capability, to the parent viewmodel, and on InitializeRow, I hide all the rows in either collection that do not correspond to the parent object. This works great, however, I cannot get the grid to redraw the row's child collections/bands on change of the Type attribute of the parent. The expected outcome would be that all the rows in one child band are hidden and the others are then shown. I have tried various approaches, but do not understand why this does not just simply work.
private void UgrdFundClosing_AfterCellUpdate(object sender, CellEventArgs e) { if(e.Cell.Row.ListObject is FundClosingAdvGridViewModel fundClosingVM) { if(e.Cell.Column.Key == nameof(FundClosingAdvGridViewModel.ClosingType)) { fundClosingVM.SetupBindingLists(fundClosingVM.ClosingType); e.Cell.Row.Refresh(RefreshRow.FireInitializeRow, true); } } }
Hello Chris,
This seems like a strange issue, especially since when exiting edit mode of the cell would trigger the InitializeRow if any changes are done, unless the UpdateMode of the grid is set to “OnUpdate” or inside the event handler there is a check whether the row is being re-initialized, so even without the following code - e.Cell.Row.Refresh(RefreshRow.Fire, true); The InitializeRow event should be triggered.
If hiding the rows in either collection works initially, but not after the user has changed the cell that determines which child rows would be shown, then a possible solution would be to add an if statement that checks if the row is not being re-initialized and execute your logic there. Afterwards the same logic to show/hide the rows could be used inside the AfterCellUpdate event handler.
If this doesn’t resolve the issue, could you please create a small isolated sample that reproduces the issue and attach it, so I can take a look at it?
Looking forward to hearing from you.
Regards, Ivan Kitanov