When the ASPxGridView
is sorted, a callback runs.
To avoid the problem, just handle the AfterPerformCallback
server-side event with the following code:
int rowIndex = (sender as ASPxGridView).FindVisibleIndexByKeyValue(keyValue);
(sender as ASPxGridView).FocusedRowIndex = (rowIndex == ASPxGridView.InvalidRowIndex) ? -1 : rowIndex;
I'll explain: keep the value of KeyValue
used to filter the data of the other components on the screen in Session
or in an ASPxHiddenField
.
If the value of keyValue
is not found, we set the FocusedRowIndex
to -1 (which unfocus the row), otherwise we always keep the same keyValue
focused.