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

Searching for a ListItem Client Side

1 Answer 72 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Robert Bross
Top achievements
Rank 1
Robert Bross asked on 16 Jul 2010, 02:56 PM
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!

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 Jul 2010, 02:36 PM
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
Tags
ListView
Asked by
Robert Bross
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or