Instead of having the user click on the expand/collapse button on the row, we want them to be able to click the entire row to expand/collapse the details template. We have implemented it like and that seems to be working, but it seems like there should be a better way to do this, perhaps even built in?
async Task OnRowClickHandler(GridRowClickEventArgs args) { args.ShouldRender = true; int currentIndexOfItem = CorporateCustomerList.IndexOf(args.Item); if (currentIndexOfItem > -1) { var state = Grid.GetState(); if(state.ExpandedRows.Contains(currentIndexOfItem)) state.ExpandedRows.Remove(currentIndexOfItem); else state.ExpandedRows.Add(currentIndexOfItem); await Grid.SetState(state); } }
We've noticed one problem with this though, which I am not sure if it is a bug in the grid or something we are doing wrong. If we have a grid with lets say 5 items/rows, and click lets say the third one, everything will work fine. If we then do some kind of filtering and only one row is displayed, the
will still return the index that row had before the filtering (in this case 3), despite the grid now only containing one row. We will then try to expand/collaps the third row, which will of course not work as only one row is displayed.
Is this a bug as we are getting an index of a row that is not being displayed? Or are they still considered to be there even though they are not displayed? If the latter, how are we supposed to handle this (which probably has noting to do with expand/collapse in particular)?
Actually, you can simplify this to that
Always gives you the wrong currentIndexOfItem if you are using filters, which might be correct regarding the actual data but not regarding what is displayed on the screen. How can we solve this?