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

Calling a client side javascript function in RadListView

1 Answer 149 Views
ListView
This is a migrated thread and some comments may be shown as answers.
AAA
Top achievements
Rank 1
AAA asked on 13 Mar 2013, 02:10 PM
In my application, when a user clicks on an item in the RadListview, I want a clientside JavaScript function to be called (similar to onclientclick in an asp.net control).
How would I call a client side JavaScript function when "RadListView1_SelectedIndexChanged" event is triggered ?

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 18 Mar 2013, 01:11 PM
Hi,

We have exposed a client-side event that you can intercept but I am not sure that it will meet your requirements. I suppose that you use a SelectedItemTemplate in your implementation and this presents a problem. Now in order to initiate this template a trip to the server has to be performed. This means that you can not avoid a postback. The client-side OnItemSelected event will be fired when an item is selected using the selectItem method like demonstrated below:
function pageLoad(sender,args)
       {
               var listView = $find("<%= RadListView1.ClientID %>");
               listView.selectItem(0, true);
       }

Following this approach you will avoid a postback thus the SelectedItemTemplate will not be initialized. If you want to fire some JavaScript event when selecting the item you can attach a OnClientClick event handler to the button which you use for selecting.

Please clarify the requirements and explain why you need to call a method in the client-side so we could give you a more precise advise.

Regards,
Angel Petrov
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
ListView
Asked by
AAA
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or