Hi,
Under certain circumstances I want to stop the user from changing the selection in the grid. I have hooked up the OnRowSelecting and OnRowDeselecting events which will both check the value of a client-side variable to say whether the action can occur. Here is an example of my client-side events code:
This works fine for selecting - the event is cancelled and the new selection is not accepted. However, when there is already an item selected in the grid, attempting to select another item results in the first item being deselected prior to the new item being selected. The GridRowDeselecting event is correctly entered and the function chooses to disallow the deselection by setting set_cancel. This then results in an IE popup window stating that the script has become unresponsive, and upon debugging the JavaScript, using set_cancel results in the OnRowDeselecting event infinitely firing and eventually the application breaks.
Can anyone suggest a reason why this is? Am I cancelling the deselection event correctly?
Under certain circumstances I want to stop the user from changing the selection in the grid. I have hooked up the OnRowSelecting and OnRowDeselecting events which will both check the value of a client-side variable to say whether the action can occur. Here is an example of my client-side events code:
function GridRowSelecting( sender, eventArgs ) |
{ |
if( CanSelectionChange() ) |
{ |
// .... do whatever I need to do |
return true; |
} |
eventArgs.set_cancel( true ); |
return false; |
} |
function GridRowDeselecting( sender, eventArgs ) |
{ |
if( CanSelectionChange() ) |
{ |
// .... do whatever I need to do |
return true; |
} |
eventArgs.set_cancel( true ); |
return false; |
} |
This works fine for selecting - the event is cancelled and the new selection is not accepted. However, when there is already an item selected in the grid, attempting to select another item results in the first item being deselected prior to the new item being selected. The GridRowDeselecting event is correctly entered and the function chooses to disallow the deselection by setting set_cancel. This then results in an IE popup window stating that the script has become unresponsive, and upon debugging the JavaScript, using set_cancel results in the OnRowDeselecting event infinitely firing and eventually the application breaks.
Can anyone suggest a reason why this is? Am I cancelling the deselection event correctly?