Hello, I have tried all day but have been unable to find out how to show/hide toolbars/buttons from Javascript.
I am controlling the editor from silverlight so I am assuming I need to use Javascript.
I would like the buttons shown in the RadEditor to depend on something the user enters.
I have edited a couple of ToolsFile.xml files to contain the buttons I require.
Calling either of the following 2 Javascript functions does nothing at all.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script language="javascript" type="text/javascript">
function setShortTools()
{
var editor = $find("<%= RadProfileEditor.ClientID %>");
editor.ToolsFile = "~/RadControls/Editor/MyToolsFileShort.Xml";
}
function setLongTools()
{
var editor = $find("<%= RadProfileEditor.ClientID %>");
editor.ToolsFile = "~/RadControls/Editor/MyToolsFileLong.Xml";
}
</script>
</telerik:RadCodeBlock>
Can anyone please tell me how to change RadEditor Buttons using Javascript (or any other method that works from Silverlight)
Many thanks in advance.
Pete
7 Answers, 1 is accepted
Many thanks for letting me know. I will try to think of something else.
Regards,
Pete.
RadEditor for ASP.NET AJAX features a full-blown client-side API for creating buttons., dropdowns and toolbars.
However, generating and configuring an editor like this fully on the client-side requires good javascript skills as well as is prone to error. I would not recommend such an approach in this scenario.
It is better to have 2 or 3 editors (each with a different tools file) loaded on the page - in hidden DIV's. Then you will be able to show whichever editor you need by chaning the DIV's style.display property. This approach is simple and efficient, because the editors are able to detect whether they (or a parent of theirs) is invisible and do not run their initialization code (until they are made visible). Thus the time it takes for the page to load should not change much.
All the best,
Tervel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
"Out of curiosity, is it possible to generate a RadEditor's toolbar JSON server-side, send it to the client via a web service (let's say), and then re-init the toolbar with the new JSON"
Yes, it is possible, however it will require quite a bit of code on the server, and a hack or two on the client (to "trick" the editor to re-initialize).
However, as far as the developer is concerned, simplicity is the name of the game - and this is how we try to do things with the RadEditor - e.g. making it very easy to configure, yet very flexible at the same time to cover the whole range of scenarios where people want to use it. Usually to achieve a goal there is more than one possibility, and usually the simplest approach is the best one.
Kind regards,
Tervel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
In fact, the default editor example available here does something very similar to that:
http://demos.telerik.com/aspnet-ajax/editor/examples/default/defaultcs.aspx
There is a radiobuttonlist control which will change the tools file of the editor by means of AJAX request.
The example uses a standard <asp:UpdatePanel> instead of RadAjaxPanel, but this is a minor difference.
Greetings,
Tervel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.