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

[Solved] Paragraph Styles, custom header

2 Answers 173 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 12 Nov 2009, 10:12 AM
I have following paragraphs defined.

<paragraphs> 
    <paragraph name="Normal" value="&lt;p&gt;" /> 
    <paragraph name="&lt;h6&gt;Local header&lt;/h6&gt;" value="&lt;h6&gt;" /> 
</paragraphs> 

In the dropdown the choices Normal and "Local header" is displayed, but when you select  a "local header" (h6) element in the editor the text "Heading 6" is displayed in the  dropdown. How can make so the text "Local header" is displayed instead?

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 17 Nov 2009, 12:23 PM
Hi Tobias,

The FontName, FontSize, FormatBlock and other dropdown headers are adaptive / sensitive on selection and they are updated depending on the information returned by the browser's queryCommandValue method. It is the browser that returns Heading 6 in the en-US localized browsers and this info is loaded in the FormatBlock dropdown header. If you would like to display another text in the FormatBlock dropdown header then you can use / enhance the code below:

<script type="text/javascript">
function OnClientSelectionChange(editor, args)
{
    var tool = editor.getToolByName("FormatBlock");
     if (tool)
    {
            setTimeout(function()
            {
                var value = tool.get_value();
                //alert(value);
                switch(value)
                {
                case "Heading 6":
                  value = value.replace("Heading 6", "Local header");
                  break;
                case "Heading 5":
                  value = value.replace("Heading 5", "Place the desired string here");
                  break;
                case "Heading 4":
                  //do something
                  break;
                }
                  
                tool.set_value(value);
            }, 0);
    }
}
</script>          
<telerik:RadEditor id="RadEditor1" runat="server" ToolsFile="~/ToolsFile.xml"  OnClientSelectionChange="OnClientSelectionChange">
    <Content>
        <h6>sample content</h6>
    </Content>
</telerik:RadEditor>


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
arnesten
Top achievements
Rank 1
answered on 18 Nov 2009, 01:12 PM
Thanks, that worked perfectly.
Tags
Editor
Asked by
Tobias
Top achievements
Rank 1
Answers by
Rumen
Telerik team
arnesten
Top achievements
Rank 1
Share this question
or