What is going wrong? My question is if the selected index is always reset but the datagrid item not being removed. If so I assume its a binding error like not having [Bindable] above the infoCollection declaration.
What seems to be happening, is that the data for the selected index appears to be correct, and the item is removed from the datagrid but the 'highlighted' index does not update on the screen. The wrong row ends up being highlighted on the datagrid. Is there an update or refresh method for the datagrid that I need to be calling?
1 person found this helpful
This might be a timing error with something being selected that is removed and the component gets confused. Try adding one of the invalidate methods before resetting the selectedindex to 0. so it would look like:
dataGrid.invalidateDisplayList(); //this could be any of the invalidate methods im not sure
dataGrid.selectedIndex = 0;
To me though this seems like the answer should be a lot simpler maybe try putting the selectedIndex into a temp variable and then setting it to 0 before removing the object using the index stored in the temp variable.
Right now im just guessing though because I dont really have time to test it myself.
I still haven't gotten this to work at all, and I've tried a number of different methods since my original post. Is there a way for me to tell the DataGrid control to just highlight the 'top' item in the list without referencing any indexes? I want to select something, remove it, and then have it automatically go back and highlight the next thing in the list...
I was never able to get this to work the way I originally wanted it to, however - there is a way to have it jump ahead to the next item in the index. I ended up just leaving everything in the ArrayCollection - but I added another flag in there that gets updated depending on what happens to the data, and then I set the selectedIndex to skip around based upon that flag. Sort of a round about way - but it worked. Thank you for your help!
Unable to get original method working, found a different method that works.