I attached a demo project to this ticket.
Here are the steps to recreate the issue:
- Click on the first row of the grid. You will see that the ASPxClientGridView.SelectionChanged event was fired once, and that the ASPxClientGridViewSelectionEventArgs were correct (e.visibleIndex = 0 and e.isSelected = true).
- Click on the second row of the grid. This time, the ASPxClientGridView.SelectionChanged event was fired twice, once because a row 0 becomes unselected and once because row 1 becomes selected. For the selected row, the ASPxClientGridViewSelectionEventArgs are ok (e.visibleIndex = 1 and e.isSelected = true), but for the unselected row, we are missing the visibleIndex (e.visibleIndex = -1 and e.isSelected = false).
This is the first problem. Here is how to reproduce the second problem: - Select the first row of the grid.
- Click the "Select Row 1" button. This will programatically select Row 1 of the grid by calling the SelectRows() method of the grid on client-side.
You will notice that the ASPxClientGridView.SelectionChanged event was fired only once this time, and only for the unselected row. Row 1 was selected programatically and this is not raising the event for the selected row.
If I summarize:
- Why the e.visibleIndex = -1 for the unselected row instead of giving the correct index?
- Why do we have the SelectionChanged event fired twice when selecting a row with the mouse, and only once when selecting a row programatically?
Thanks, Normand
Hello Normand,
I appreciate your detailed report, however the issue you faced is not a bug. If you examine the additional properties of the ASPxClientGridView.SelectionChanged event argument, you will be able to determine why client-side event is raised twice.
The e.isAllRecordsOnPage property tells you that all records on the page are selected or deselected. That is why the e.visibleIndex equals -1.
Client-side events are raised for all possible actions, however, the server-side event is raised only once when the form is posted to the server. If we send callbacks often, you will face performance issues. On the client side all events are processed quickly.
Thanks,
Vest
Hi Vest,
Thanks for your fast answer. But I still do not understand. First, I understand the client-side event fired twice, and this is perfect.
What I do not understand is this sentence in your answer:
"The e.isAllRecordsOnPage property tells you that all records on the page are selected or deselected. That is why the e.visibleIndex equals -1."
What is the relation between isAllRecordsOnPage and visibleIndex?
And the other thing I do not understand is why the SelectRows() client-side method does not fire the SelectedIndexChanged client-side event of the grid?
Thanks, Normand