Searching for a ListItem Client Side

2 posts, 0 answers
  1. Robert Bross
    Robert Bross avatar
    27 posts
    Member since:
    Oct 2012

    Posted 16 Jul 2010 Link to this post

    Does anyone know how to do this? I looked through the docs and forums and could only find information on selecting the "first" item. The reason I need this is I have a certain item selected by handling the onclick event of the item within the <ItemTemplate>. However, after a postback I need to be able to reselect the item again. Any help or advise would be greatly appreciated! Thanks!
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 20 Jul 2010 Link to this post

    Hi Robert,

    As RadListView is a look-less control and does not have any built-in layout, there is no notion of item client-side object. However you can use the server-side RadListViewDataItem's DisplayIndex  to trigger client-side selectItem method, similar to the following:

    <telerik:RadListView runat="server" ID="RadListView1" 
            OnNeedDataSource="RadListView1_NeedDataSource">
            <ItemTemplate>
                <input type="button" value="click me to select" onclick='selectItem(<%#Container.DisplayIndex %>)' />
            </ItemTemplate>
            <SelectedItemTemplate>
                selected
            </SelectedItemTemplate>
        </telerik:RadListView>
        <script type="text/javascript">
            function selectItem(displayIndex) {
                $find("<%=RadListView1.ClientID %>").selectItem(displayIndex);
            }
        </script>

    All the best,
    Rosen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top