You can attach the client event OnCommand. This will be raised for each grid command which is about to be triggered (sorting, paging, filtering, editing,
etc.) before postback/ajax request except
hierarchy/grouping expand/collapse action.
aspx:
<ClientSettings>
<ClientEventsOnCommand="RaiseCommand"/>
<ClientSettings>
JavaScript:
functionRaiseCommand(sender, args)
{
if(args.get_commandName() == "CancelUpdate")//check for the condition
{
//your code here
}
}
Also refer the following documentation for more on this: OnCommand