I have a requirement to maintain the selection on a XamGrid after refreshing the data.
For example,
The grid is loaded and I selected the 3rd row and after that I need to reload the data and after reloading the records the 3rd row (or the previosly selected record) should be selected.
i.e it should be highlighted (so that user can able to see the record that was selected before ).
Can somebody help me on this?
Thanks a lot for your suggestions. It works now!
Hello,
Adding the row to the SelectedRows collection will highlight the row as expected.
I have added a sample that demonstrates this. In my sample, the button at the top will change the DataContext of the XamGrid. When the data is reloaded, the same selected row appears selected afterwards.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using Infragistics 2018 Volume 2.
If the project does show the product feature working correctly, then more information will be needed to reproduce the issue in a sample that can be used for debugging. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing. This can be done by either making the sample that I provided more like your application or by isolating the behavior from your application by removing dependencies on any third parties or databases.
Please let me know if I can provide any further assistance.
XamGrid_SelectionAfterRefresh.zip
Hi,
Thank you for your suggestion. I tried doing what you said , but visually after refreshing data, the focus on the previous selected cell in XamGrid is lost. I want the cell to be highlighted even after refresh, just like when we click the mouse on the XamGrid cell.
Thank you for posting in our forums!
You will need to keep track of the selected cell before the refresh occurs, and then afterwards set the selection again.
Please see the following on setting the selection programmatically for more information on this.
https://es.infragistics.com/help/wpf/xamgrid-setting-selection-programmatically
If you need further assistance with this, please let me know and I will be glad to help.