I want to add a client-side JavaScript event handler that will fire each time a row is selected or deselected on an ASP.NET Telerik RadGrid and I need to add it from JavaScript without server-side code. How can I accomplish this?
1 Answers
0
votes
You can achieve this by using RadAjaxManager. ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
onajaxrequest="RadAjaxManager1_AjaxRequest"></telerik:RadAjaxManager>
JS:
<script type="text/javascript">
function onclientrowclick(sender, args) {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
}
</script>
C#:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
//your code
}
EDIT:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" AllowMultiRowSelection="true" >
<ClientSettings Selecting-AllowRowSelect="true">
<ClientEvents OnRowSelecting="OnRowSelecting" OnRowDeselecting="OnRowDeselecting" />
</ClientSettings>
</telerik:RadGrid>
JS:
function OnRowDeselecting(sender, args) {
alert("deselect");
}
function OnRowSelecting(sender, args) {
alert("select");
}
<telerik:RadGrid ID="RadGrid1" runat="server"> <ClientSettings> <ClientEvents OnRowSelecting="RowSelecting" /> </ClientSettings> </telerik:RadGrid>- jac