Calling a client side javascript function in RadListView

2 posts, 0 answers
  1. AAA
    AAA avatar
    17 posts
    Member since:
    Mar 2013

    Posted 13 Mar 2013 Link to this post

    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 control).
    How would I call a client side JavaScript function when "RadListView1_SelectedIndexChanged" event is triggered ?
  2. Angel Petrov
    Angel Petrov avatar
    1075 posts

    Posted 18 Mar 2013 Link to this post


    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.

    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.
Back to Top