RadListBox Inside EditForm

2 posts, 0 answers
  1. Manuel
    Manuel avatar
    1 posts
    Member since:
    Oct 2012

    Posted 17 Dec 2014 Link to this post

    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
  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 22 Dec 2014 Link to this post

    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.

  3. DevCraft R3 2016 release webinar banner
Back to Top