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

ImageUrl on EditorDropDown does not display?

1 Answer 41 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Lextendo
Top achievements
Rank 1
Lextendo asked on 15 Jul 2011, 08:15 PM
Hi,

I generate create a EditorToolGroup in code behind like this:

Public Shared Sub AddEditorToolbarGroup(ByRef ed As RadEditor)
      Dim tg As New EditorToolGroup
      tg.Tag = "EmoticonsGroup"
      AddIconsDropDown(tg, EtnicGroup.Afro)
      AddIconsDropDown(tg, EtnicGroup.Hindi)
      AddIconsDropDown(tg, EtnicGroup.Java)
      AddIconsDropDown(tg, EtnicGroup.Indian)
      AddIconsDropDown(tg, EtnicGroup.China)
      AddIconsDropDown(tg, EtnicGroup.Bakra)
      ed.Tools.Add(tg)
  End Sub
  Private Shared Sub AddIconsDropDown(ByRef etg As EditorToolGroup, ByVal etnicity As String)
      Dim smileys As Dictionary(Of String, String) = EtnicSmileys(etnicity)
      'Dim sp As EditorSplitButton = New EditorSplitButton("Emoticons_" + etnicity)
      'sp.Text = "Emoticons_" + etnicity
      'sp.ImageUrl = "Smiley/Smiley_Afro_Happy.gif"
      'For Each smiley As KeyValuePair(Of String, String) In smileys
      '    Dim img As String = String.Format("<img src='Smiley/{0}.gif' height='22' widht='22' onmouseover='this.width=40;this.height=40;' onmouseout='this.width=22;this.height=22;'>", smiley.Value)
      '    Dim url As String = String.Format("Smiley/{0}.gif", smiley.Value)
      '    'sp1.Items.Add("<img src='icons/1.gif'>", "icons/1.gif");
      '    sp.Items.Add(New EditorDropDownItem() With {.Name = img, .Value = url})
      'Next
      'etg.Tools.Add(sp)
      Dim edd As EditorDropDown = New EditorDropDown() With {.Name = "Emoticons_" + etnicity, _
                                                             .Text = "Emoticons_" + etnicity, _
                                                             .Width = Unit.Pixel(22), _
                                                             .ImageUrl = String.Format("./Smiley/Smiley_{0}_Happy.gif", etnicity), _
                                                             .ItemsPerRow = 6, _
                                                             .ShowIcon = True, _
                                                             .ShowText = False _
                                                            }
      For Each smiley As KeyValuePair(Of String, String) In smileys
          Dim img As String = String.Format("<img src='Smiley/{0}.gif' height='22' widht='22' onmouseover='this.width=40;this.height=40;' onmouseout='this.width=22;this.height=22;'>", smiley.Value)
          Dim url As String = String.Format("Smiley/{0}.gif", smiley.Value)
          'sp1.Items.Add("<img src='icons/1.gif'>", "icons/1.gif");
          edd.Items.Add(New EditorDropDownItem() With {.Name = img, .Value = url})
      Next
      etg.Tools.Add(edd)
  End Sub

The dropdowns are filled as expcted, but the dropdown should display my ImgUrl Icon, not te .Text property...
I prefer to use the EditorSplitButton, but it has the same problem: no icon image! I'm sure the path to the icon is correct, since the items are filled properly... What am I doing wrong here?

TIA,
Alex

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 20 Jul 2011, 04:59 PM
Hello Lextendo,

The custom dropdowns of RadEditor do not offer IconUrl property and the only way to apply an icon to the head of the dropdown is via CSS or JavaScript as shown in the following demo: Custom Dropdowns, e.g..

<style type="text/css">
    .reTool .Emoticons
    {
        background-image: url(icons/1.gif);
    }
</style>

Using the code below you can change programmatically the icon in the head:
<script type="text/javascript">
function OnClientCommandExecuting(editor, args)
{
    var name = args.get_name(); //The command name
    var val = args.get_value(); //The tool that initiated the command
 
    if (name == "Emoticons")
    {                                                                               
        //Set the background image to the head of the tool depending on the selected toolstrip item
        var tool = args.get_tool();
        var span = tool.get_element().getElementsByTagName("SPAN")[0];
        span.style.backgroundImage = "url(" + val + ")";
...


Kind regards,
Rumen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Editor
Asked by
Lextendo
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or