This is a migrated thread and some comments may be shown as answers.

Preventing Row De-Selection with Javascript

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Smith
Top achievements
Rank 1
Smith asked on 27 Apr 2012, 09:41 PM
Hi,

I have a scenario that I'm hoping someone here can provide guidance on...

I have a RadGrid programmed so that when a row is selected it populates a user control elsewhere on the page and the row in the grid is highlighted as selected. If a user has entered or changed information for that item in the user control and then tries to select another row without saving, I've used javascript to remind them to save. If they select OK, it ignores the changes and loads the new item from the newly selected row. If they select Cancel, it prevents the page from posting.

I've first used the OnRowClick ClientEvent, and it would work as I expected, but the newly selected row would still be shown as "selected" even if I canceled the postback. I then tried the OnClientSelecting ClientEvent and it prevented the newly selected row from displaying as "selected", but the current row still lost it's "selected" row styling. What event should I use to prevent the currently selected row from losing its highlighted "selected" styling in the grid if the user selects "Cancel"?

Thanks for any help!

Smith

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 02 May 2012, 04:13 PM
Hello Smith,

I would suggest that you utilize the OnRowSelecting and / or OnRowDeselecting client side events. Both events are cancel-able and provide additional information about the item being selected/deselected through the event arguments.

I hope this helps.

Kind regards,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Smith
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or