Wednesday, September 14, 2011

client-side ASPxClientGridView.SelectionChanged event is raised twice

Regarding to issue: ASPxGridView - SelectionChanged event fires twice when selecting rows manually, and once when selection is performed on the client side

Reason: The ASPxClientGridView.SelectionChanged event is raised each time row selection is changed. If ASPxGridView allows selecting only one row, the previously selected row is unselected before another row is selected. Row unselection is also a selection change action. Therefore the SelectionChanged event is raised. Next time this event is raised when the new row is selected. So, a callback is sent twice in the sample project.
You can use the e.isSelected property to check whether a row has been selected or unselected.

Solution: It is the behavior of the grid, so you need to determine that whether row get select or unselect.

The client-side ASPxClientGridView.SelectionChanged event is raised twice
 (e.processOnServer == true), add the following condition to your code to
enable both ASPxButtons on the client side only when DataRow is selected:

SelectionChanged="function(s, e) {
if (e.isSelected) {
clBtnMentes.SetEnabled(e.isSelected);
clBtnMegsem.SetEnabled(e.isSelected);
}
}";



No comments :

Post a Comment