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

Radeditor Custom button

1 Answer 142 Views
This is a migrated thread and some comments may be shown as answers.
oprisan tudorel
Top achievements
Rank 1
oprisan tudorel asked on 31 May 2010, 09:40 AM

I just started using Rad Controls, and i have some problems.
I want to put a custom button in RadEditor control, (actually it's a dropdown list). Each of the values of the dropdown list, will lead to a function that changes the tools file(xml) that the radEditor uses.
I already made the dropdown list, and created the function to do this. But the problem is that, after choosing a certain value, the page is set to be reloaded, and it will load the Editor with the default tools file. Is there any way to accomplish this? I was thinking of some way to reload only the RadEditor with the new tools file, but i haven't seen a command to do just that.

for the moment is use this script to change the tools file.

  <script type="text/javascript"
                 Telerik.Web.UI.Editor.CommandList["Custom"] = function (commandName, editor, args) { 
                     alert("Custom command 1"); 
                     //for example you can apply bold formatting by firing the"Bold"); 
                 Telerik.Web.UI.Editor.CommandList["Drop1"] = function (commandName, editor, args) { 
                     alert("Custom command 2"); 
                     // Execute your code here, provide it with any arguments that you need, etc. 
                 Telerik.Web.UI.Editor.CommandList["ButtonPresets"] = function (commandName, editor, oTool) { 
                     //alert("Value Selected: " + oTool.get_value()); 
                     //var editorName = "ContentPlaceHolder2_RadEditor2Wrapper" 
                     //document.getElementById(ContentPlaceHolder2_RadEditor2Wrapper).ToolFile = "~/RadEditor Tools/ToolsFile" + oTool.get_value() +".xml" 
                     editor.ToolsFile = "~/RadEditor Tools/ToolsFile" + oTool.get_value() + ".xml" 
                     //documentdocument.location = document.location; 

The second problem i seem to have, involves the customization of an already existing button - FullScreen. I want the button to co to full screen, but the textarea of the edited text to remain the same. In other words, when using fullscreen i wish to see the tools in the upper bar, just like fullscreen. But the editing content to remain as the same size as in the original page. If it was 200x200px i want it to remain the same.
The third and final problem i am facing, and have no ideea how to solve is to autohide, via button, certain sets of tools, let's say i don't want to see the font size&alignment, i should be able to show/hide those with one button, something like and collapsible panel. I hope i made myself clear, and to receive any help soon.

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 02 Jun 2010, 01:55 PM
Hi Oprisan,

RadEditor does not offer the functionality to change the ToolsFile entirely on the client side. In order to achieve this goal, you need to trigger an Ajax request, and change the RadEditor's ToolsFile on the server-side. In the following article you can find a simple example on how to trigger an Ajax request from a custom tool:
Adding the Save and Cancel Buttons to a Toolbar

For your convenience I have attached a sample project implementing the approach mentioned above.

Regarding the second question, I suggest you to use the same approach as the ToolsFile to change the ToolsbarMode property to PageTop, e.g.:
RadEditor1.ToolbarMode = EditorToolbarMode.PageTop;

Sincerely yours,
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Asked by
oprisan tudorel
Top achievements
Rank 1
Answers by
Telerik team
Share this question