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

Resize vertical height to fit RadEditor contents

9 Answers 410 Views
Editor
This is a migrated thread and some comments may be shown as answers.
genesplitter
Top achievements
Rank 2
genesplitter asked on 29 Oct 2007, 09:13 PM
Is it possible to automatically resize the vertical height of the RadEditor to fit the content? (similar to the attachResize event of the classic RadEditor)

9 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 30 Oct 2007, 11:36 AM
Hi Donald,

Thank you for your feature request!

Currently, the requested feature is not supported by RadEditor "Prometheus" but it is in our ToDo list and we will do our best to implement it until the end of the year.

Let us know if you have any other inquires.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paul Hopper
Top achievements
Rank 1
answered on 08 Nov 2007, 05:04 PM
An admittedly poor workaround I've figured out for this in the meantime is to add a prerender function as follows:
protected void radEditor_PreRender(object sender, EventArgs e)  
{  
    radEditor.ControlStyle.Reset();  

The big downside to that, though, is that the height in edit mode is very short by default.  (The user can then drag the window so that it is bigger, but it's annoying nonetheless.)

I was hoping a fix for this would have made it in yesterday's update, but no such luck.
0
Paul Hopper
Top achievements
Rank 1
answered on 08 Nov 2007, 08:21 PM
This actually appears to work better than the "fix" I suggested a few hours ago...

protected void radEditor_PreRender(object sender, EventArgs e)  
{  
    if (radEditor.Enabled == false)  
        radEditor.ControlStyle.Reset();  
}  
 

Basically, if the editor is enabled (i.e., in edit mode), it'll keep whatever height you specify or use the default height.  If it's not in edit mode, this will clear the ControlStyle, where the default height lives, and the text will flow as far down the page as necessary.
0
Rumen
Telerik team
answered on 12 Nov 2007, 02:01 PM
Hi Paul,

We do appreciate your help in this forum thread and we updated your telerik points for the provided solution.


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Dimo
Top achievements
Rank 1
answered on 22 Apr 2010, 04:28 PM
Hi!
Is already there possibility to limit RadEditor content to fit in specified dimensions (width or height)?
0
Rumen Jekov
Top achievements
Rank 1
answered on 23 Apr 2010, 01:37 AM
Hi,

Have you tried to set the AutoResizeHeight property of RadEditor to true?

Greetings,
Rumen
0
Rumen
Telerik team
answered on 23 Apr 2010, 01:49 PM
Hi again,

You can also try the code below, which could be helpful for implementing your requirement:

<script type="text/javascript">
     function checkEditor(editor, ev) {
         var targetHeight = editor.get_document().body.scrollHeight;
         var allowedHeight = editor.AllowedHeight;
 
 
         if (targetHeight > allowedHeight) {
             alert("Maximum allowed size content height is 350 pixels");
 
             if (ev) {
                 ev.returnValue = false;
                 ev.cancelBubble = true;
             }
 
             return false;
         }
         return true;
     }
 
     function OnClientCommandExecuted(editor, commandName, tool) {
         var allow = checkEditor(editor);
 
         if (false == allow) {
             editor.undo(1);
         }
     }
 
     function OnClientLoad(editor) {
         var iframe = editor.get_contentAreaElement();
         iframe.style.height = "310px";
         iframe.style.border = "1px solid red";
 
         editor.AllowedHeight = "400"; //set here the desired allowed max height
 
         var resizeFnRef = function(e) { checkEditor(editor, e) };
 
         editor.attachEventHandler("keydown", resizeFnRef);
 
     
</script> 
<telerik:RadEditor id="RadEditor1"  
    Height = "350px"
    AutoResizeHeight="true"
    OnClientLoad="OnClientLoad"
    OnClientCommandExecuted = "OnClientCommandExecuted"
    EditModes="Design"
    Runat="server">
    <Modules>
        <telerik:EditorModule Name="RadEditorStatistics" Enabled="false" />
    </Modules>
    <Tools><telerik:EditorToolGroup><telerik:EditorTool Name="Bold" /></telerik:EditorToolGroup></Tools>
</telerik:RadEditor>

Please, note that the requested functionality is not offered by RadEditor and the code above is not supported.

Regards,
Rumen
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.
0
Dimo
Top achievements
Rank 1
answered on 27 Apr 2010, 07:25 AM
Hi!
Thank you for your help!
I intereset mainly from width limit. How your code should be amended for image width restriction?
0
Rumen
Telerik team
answered on 27 Apr 2010, 04:10 PM
Hi Dimo,

Please, check the solutions provided in these KB articles:
http://www.telerik.com/support/kb/aspnet-ajax/editor/disabling-image-resize-in-radeditor-classic-and-prometheus.aspx
and
http://www.telerik.com/support/kb/aspnet-ajax/editor/resizing-images-proportional-in-internet-explorer.aspx

They could be helpful for your scenario.

Best wishes,
Rumen
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.
Tags
Editor
Asked by
genesplitter
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Paul Hopper
Top achievements
Rank 1
Dimo
Top achievements
Rank 1
Rumen Jekov
Top achievements
Rank 1
Share this question
or