Mira, from the telerik support team, told me last week to use:
>>From your posts I assume that you have the EnablePostBackOnRowClick property set to true. To prevent postback if the confirm window returns false, please use the set_cancel() accessor method of the event arguments.
That errors and I read this post from 2009 where it says the grid no longer supports set_cancel()
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-cancel-in-onrowclick-event.aspx
When trying to cancel the click, I had EnablePostBackOnRowClick="true"
And when trying to activate the click, I had: EnablePostBackOnRowClick="False"
I am using this for my grid click event:
grdGrid.ClientSettings.ClientEvents.OnRowClick = "GetDirtyGridRowClickReviewer" |
So I tried several other things from other posts and none work:
<script language="JavaScript" type="text/javascript"> |
<!-- |
function GetDirtyGridRowClickReviewer(sender, eventArgs) |
{ |
var sContinue; |
if (isDirty == 1) { |
sContinue = window.confirm("You have unsaved changes. Please select CANCEL if you would like to return to the form to save your changes. Please select OK if you wish to proceed and lose your changes."); |
if (sContinue != true) { |
//4/13/2010 |
//http://www.telerik.com/community/forums/aspnet-ajax/grid/deselecting-event-set-cancel-true-does-not-preserve-selectcolumn-status.aspx |
// below does nothing, continues to selected row... |
// var grid = $find("<%= grdReviewer.ClientID %>"); |
// var masterTableView = grid.get_masterTableView(); |
// row = masterTableView.get_dataItems()[0]; |
// setTimeout('row.set_selected(true);', 10); |
// below errors...4/12/2010 |
// says isn't supported as of 2009 |
// http://www.telerik.com/community/forums/aspnet-ajax/grid/set-cancel-in-onrowclick-event.aspx |
// eventArgs.set_cancel(true); |
// 4/9/2010 |
// below cancels everything, all buttons on page, everything. |
//$find("<%=grdReviewer.MasterTableView.ClientID %>").cancelAll(); |
return false; // cancel so they can save |
} |
} |
isDirty = 0; // reset if continue |
//http://www.telerik.com/community/forums/aspnet-ajax/grid/cancel-rowclick-event.aspx |
// 4/13/2010 set EnablePostBackOnRowClick="False" |
// below errors |
// doPostBack('<%=grdReviewer.ClientID %>'); |
// 4/13/2010 |
//http://www.telerik.com/community/forums/aspnet-ajax/grid/row-double-click-edit-and-row-click-edit-update-on-grid.aspx |
// doPostBack("<%= grdReviewer.UniqueID %>", "RowClicked:" + sender.get_masterTableView().get_dataItems()[editedRow]._itemIndexHierarchical); |
//http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/editondblclick/defaultcs.aspx |
// below errors object expected... |
var editedRow; |
editedRow = eventArgs.get_itemIndexHierarchical(); |
doPostBack("<%= grdReviewer.UniqueID %>", "RowClicked:" + sender.get_masterTableView().get_dataItems()[editedRow]._itemIndexHierarchical); |
return true; |
} |
// --> |
</script> |
Below are the links to the things I've tried.
http://www.telerik.com/community/forums/aspnet-ajax/grid/deselecting-event-set-cancel-true-does-not-preserve-selectcolumn-status.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-cancel-in-onrowclick-event.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/cancel-rowclick-event.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/editondblclick/defaultcs.aspx
Can someone please provide a working example of canceling or activating row click client side after asking if you wish to proceed?
Thanks!