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

Setting Custom Dropdown selected Value

3 Answers 94 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Nishan Perera
Top achievements
Rank 1
Nishan Perera asked on 04 Feb 2010, 03:14 PM
Hi,

I have a custom dropdown for line spacing. Functionality works fine. users can set the line spacing. But when they select a text which has line spacing custom dropdown does not change to the selected value



How can I set this up depend on the editor selection.

Thanks

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Feb 2010, 05:03 PM
Hello Nishan,

The getSelectedElement() method of RadEditor returns a reference to the currently selected HTML element in the RadEditor for ASP.NET AJAX content area. You can use this method to get a reference to the currently selected element and check whether it has applied lineHeight css property and modify its value. It does not have such a property then set it.


Kind regards,
Rumen
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Nishan Perera
Top achievements
Rank 1
answered on 08 Feb 2010, 10:24 AM
HI,

Thank you for your reply. After digging this more. I have found out dropdown selected index is changing but its not set on editor toolbar.

        ToolLineHeight._selectedIndex    6    JS Property.

Is This a browser issue.

Nishan
0
Rumen
Telerik team
answered on 08 Feb 2010, 04:56 PM
Hi Nishan,

By design, custom dropdowns do not provide this functionality out-of-the box. Nevertheless, it is possible to change the displayed value of the dropdown with the following sample code:
Copy Code
function OnClientSelectionChange(editor, args)
{
    var lineSpacingTool = editor.getToolByName("LineSpacing");
    var toolItems = lineSpacingTool.get_items();
    var cArea = editor.getSelection().GetParentElement();
     
    if (cArea.tagName == "P" || cArea.tagName == "FONT" || cArea.tagName == "STRONG")
    {
        for(var i = 0; i < toolItems.length; i++)
        {
            if(toolItems[i][0] == cArea.style.lineHeight)
            {
                lineSpacingTool.set_text(toolItems[i][1]);
                return;
            }
            else
            {
                lineSpacingTool.set_text("Line Spacing");
            }
        }
    }
}


Regarding the displayed value of the RealFontSize dropdown - the information displayed in the RealFontSize dropdown header is returned by the browser's queryCommandValue method. Firefox, Safari and Chrome return the font-size information in pixels. Internet Explorer returns the font-size in points. For the time being we do not plan to enhance the current mechanism of RealFontSize tool to display only values in pixels or points in all browsers, because this can introduce unwanted side effects during the conversion from pixels to points.


Greetings,
Rumen
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Editor
Asked by
Nishan Perera
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Nishan Perera
Top achievements
Rank 1
Share this question
or