Image won't display on selection

2 posts, 0 answers
  1. Johnathan
    Johnathan avatar
    39 posts
    Member since:
    Sep 2012

    Posted 08 Oct 2015 Link to this post

    Hello. I'm working with a raddropdownlist control contained within radfilter and I have this drop down list display images for different each list item. The ImageDropDown image shows you what the display looks like when the drop down list is open. If I select a drop down list item, the item get selected but nothing displays (shown in the MissingSelection Image). However, once I apply the radfilter selection, the image will appear selected on postback (ImageSelected Image). Here's the code-behind code that is used to create the raddropdownlist for the radfilter:

    Protected Sub RadFilter1_ExpressionItemCreated(sender As Object, e As RadFilterExpressionItemCreatedEventArgs) Handles RadFilter1.ExpressionItemCreated
            Dim oConn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("iTask").ConnectionString)
            Dim oCmd As New SqlCommand
            Dim oData As SqlDataReader

                Dim singleItem As RadFilterSingleExpressionItem = TryCast(e.Item, RadFilterSingleExpressionItem)
                If singleItem IsNot Nothing AndAlso singleItem.FieldName = "Flag" AndAlso singleItem.IsSingleValue Then
                    Dim dropDownList As RadDropDownList = TryCast(singleItem.InputControl, RadDropDownList)

                    With dropDownList
                        .Width = 50
                        Dim oBlankItem As New DropDownListItem("")
                        With oCmd
                            .Connection = oConn
                            .CommandType = CommandType.StoredProcedure
                            .CommandText = "iTask_Select_Flags"
                        End With
                        oData = oCmd.ExecuteReader
                        Do While oData.Read
                            Dim oItem As New DropDownListItem("")
                            oItem.Text = "<img src='" & CoreComponents.sImageRoot & oData("ImageFileName").ToString & "' style='cursor:pointer;' border='0'/>"
                            oItem.ToolTip = oData("Name").ToString
                            oItem.Value = oData("ImageFileName").ToString
                            'oItem.ImageUrl = CoreComponents.sImageRoot & oData("ImageFileName").ToString
                        .OnClientItemSelected = "OnClientItemSelected"
                        '.OnClientSelectedIndexChanged = "OnClientSelectedIndexChanged"

                    End With
                End If
            Catch ex As Exception
                oConn = Nothing
                oCmd = Nothing
                oData = Nothing
            End Try

        End Sub


    I attempted to use the OnClientItemSelected & OnClientSelectedIndexChanged JS code to set the image in the text element of the RadDownDownList control, but to no avail. Here's that code as well. Any help on this issue would be greatly appreciated.

     function OnClientItemSelected(sender, eventArgs) {
                        alert('function called!');
                        var item = eventArgs.get_item();
                        //alert("You selected " + item.get_text() + " with value " + item.get_value());
                        sender.get_textElement().innerHTML = "<img src='<%=CoreComponents.sImageRoot%>" + item.get_value() + "' border='0'/>";

                    function OnClientSelectedIndexChanged(sender, eventArgs) {
                        alert("You selected item with index : " + eventArgs.get_index());
                        sender.get_textElement().innerHTML = sender.get_items().getItem(eventArgs.get_index()).get_text();

  2. Nencho
    Nencho avatar
    1646 posts

    Posted 13 Oct 2015 Link to this post

    Hello Johnathan,

    I am afraid that appending the ImageUrl in the textElement of the control is not supported, because the RadDropDownList manages only the text of the element.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top