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

maxlenght for editor in grid

3 Answers 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 01 Mar 2009, 02:47 PM
Hi,

I have a grid (hyrachical) where I edit the detail rows.
The Form template looks like this:

    <EditFormSettings EditFormType="Template" > 
    <FormTemplate> 
        <asp:Button ID="Button1" Text="Update" runat="server" CommandName="Update"></asp:Button>&nbsp;&nbsp;  
        <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button> 
        <br /> 
        <telerik:RadEditor ToolsFile="/Images/ToolsForStrings.xml" Skin="Office2007" Language="de-DE" ID="edTheString" runat="server" Width="760px" Height="150px" Content='<%# Bind("TheString") %>'>  
        </telerik:RadEditor> 
 
 
    </FormTemplate> 
    </EditFormSettings> 
 
 I found the article about setting maxlength (via jscript) - but using this srcipt results in "The Name edTheString is not....".

Now my questions:
a.) what is the correct ID for this scenario?
b.) can something like this be handled with a custom module?

My Idea for b.) - there is a statistic module which shows me the number of letters.
Is it possible to write an own module which also counts the number of letters - but rejects changes when the length is longer than XXX

By the way - "MaxLength" is a very common thing - especially when you work with databases.
So it would be a great idea to have this as "property" like an asp:TextBox has it.

Regards

Manfred

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Mar 2009, 09:48 AM
Hello Manfred,

Please, see the following Validator support example which demonstrates how to attach a custom validator to RadEditor and restrict the content length.

If you do not like this solution, you can create your own statistics custom module. For your convenience I have attached the code of the statistics module used by the editor. You can modify it as per your requirements.

All the best,
Rumen
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.
0
ManniAT
Top achievements
Rank 2
answered on 05 Mar 2009, 12:23 PM
Hi,

thank you for your help.
My problem - with "Custom Validator" (what I do at the moment) I get a bad situation.

The approach is "maxlenght" of a textbox. The user types (pastes) text.
If the limit (maxlenght) is exeeded - no more text can be entered.

In my case (database) the limit is the number of chars - including the html tags.
The statistic module can be changed not to "exclude" those tags.
But it only counts the things - nothing more.
This was my question:
A statistic module which counts -- but rejects changes when the length is longer than XXX

The sample you linked does avoid that to long (short in this case but that could be changed) data is entered.
BUT - and that is a real problem - it does the things on submit.

So the user types, and types, and types -- just to see a few minutes later - it was too much.
OK - he did a lot of work (writing text) for nothing.
Next he reduces the text - the error message stays - until he hits submit again.
And this with up to three editors - I guess they would hate me for such a thing :)

Again (you may have overseen) there is a sample on your site which checks for the length.
BUT - It assumes that the editor is already present - so that I can find it's ID.
My situation - the editor is part of a "detail record edit template" in an ajaxified grid.
So the sample does not work since I can't find the ID(s) of the editor(s) on the page.

Regards

Manfred
0
Rumen
Telerik team
answered on 09 Mar 2009, 05:33 PM
Hello Manfred,

Did you try to get a reference to the editor by attaching a function to the OnClientLoad property of RadEditor, e.g.

<telerik:RadEditor id="RadEditor1" runat="server" OnClientLoad="OnClientLoad"></telerik:RadEditor>
 <script type="text/javascript">
        var editor = "";
        function OnClientLoad(sender, args)
        {
                editor = sender; //get a reference to RadEditor object
        }
    </script>



Best regards,
Rumen
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.
Tags
Editor
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Rumen
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or