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

RadListBox Inside EditForm

1 Answer 73 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Manuel asked on 17 Dec 2014, 08:18 PM
Hi All

This is my scenario

I have a RadGrid, then I have an EditFormTemplate and inside I have a RadListBox, I'm able to select a value from codebehind, but I want to scroll the ListBox to the selected when the EditForm is showing, I followed this post  but I'm not able to do it.

Here is my test code 

<telerik:RadGrid ID="Radgrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
        <EditFormSettings EditFormType="Template">
        <PopUpSettings Width="620px" Modal="false" Height="550px" />
                <telerik:RadListBox ID="RadListBox1" runat="server" DataSource="DS" OnClientSelectedIndexChanged="selectedIndexChanged">
            <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID">

Code Behind
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridDataItem Then
            Dim editItem As GridDataItem = DirectCast(e.Item, GridDataItem)      
            Dim ddlCurrency As RadListBox = DirectCast(editItem.FindControl("RadListBox1"), RadListBox)
            If ddlCurrency IsNot Nothing Then
                Dim item As RadListBoxItem = ddlCurrency.FindItemByText(strCurrency)
                If item IsNot Nothing Then
                    ddlCurrency.SelectedValue = hdnValue.Value
                End If
            End If
         End If
     End Sub

function selectedIndexChanged(sender, args)
    var item = args.get_item();

I know that I can only use the scrollIntoView() inside JavaScript but the function  selectedIndexChanged is not firing, is there a way to scroll when I select the item in the code behind or server-side? 
Thanks in advance

1 Answer, 1 is accepted

Sort by
Peter Filipov
Telerik team
answered on 22 Dec 2014, 12:24 PM
Hello Manuel,

Here is my suggestion for your case:
1. Handle the pageLoad event at the client side
2. Find the RadListBox control
3. Get the selected item by calling get_selectedItem() method, after that invoke the scroll into view function.

Peter Filipov

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question