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

Is there any option to set content size as Inches in RAD Editor?

1 Answer 63 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Saravanan
Top achievements
Rank 1
Saravanan asked on 30 Oct 2012, 02:53 PM
Hi,

We have one senrario ,  
Is there any option to set page size in radeditor, If its exceed more than the page size we should not allow the user to enter.

The user enter the content in to the RAD Editor Content Box, If the content exceed more than 6 inches in Height (Page Size), The user trying to do Export PDF, by that time  I need to send the validation message. Your page size is more than 6 inches . 

"This Validation has to be done before Export PDF


How can handle the validation in Rad Editor. 


Regards,
Saravanan M

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 31 Oct 2012, 03:20 PM
Hi,

RadEditor does not offer the required feature built-in because the HTML markup is just a string it is not able to determine if the text entered will fit in a certain amount of space. However, you can enhance the provided code below to fit your scenario. Here is a basic example on how to limit the line length in the editor content area:

<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)
{
//Set content area to be one inch high
var iframe = editor.get_contentAreaElement();
iframe.style.height = "350px";
iframe.style.border = "1px solid red";

editor.AllowedHeight = iframe.offsetHeight;

var resizeFnRef = function (e){checkEditor(editor, e)};

editor.attachEventHandler("keydown", resizeFnRef);

}
</script>
<telerik:RadEditor id="RadEditor1"
Height = "350px"
OnClientLoad="OnClientLoad"
OnClientCommandExecuted = "OnClientCommandExecuted"
Runat="server">
</telerik:RadEditor>

Greetings,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Editor
Asked by
Saravanan
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or