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

RadEditor Current Cursor Position

3 Answers 79 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dinakaran
Top achievements
Rank 1
Dinakaran asked on 17 Jan 2014, 01:45 PM
Hi,
      I need to find the RadEditor cursor position to place some text from another screen,i have tried to find the cursor position at the end of the each line but i can't able to find the cursor position between the words,please refer the images to analyse.

Thanks & Regards,
      Dinakaran

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 21 Jan 2014, 09:07 AM
Hi Dinakaran,

You can use editor.pasteHtml function to insert any content to the cursor position.

Another way is to get the RadEditor range object - editor.getSelection.getRange(true). Then using range.pasteHTML function for IE7 and IE8 and range.insertNode for other browsers to insert content.

Regards,
Nikolay
Telerik
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 the blog feed now.
0
Marco
Top achievements
Rank 1
answered on 19 Aug 2014, 09:55 AM
Hi,
I'm using pasteHtml to add some text and it's correctly added on cursor position on Chrome and FF but non on ie9 or ie10. On both IE test is put at the start of the text area. It's known issue ?

Thanks,
Marco
0
Nikolay
Telerik team
answered on 21 Aug 2014, 12:18 PM
Hi,

Internet Explorer does not keep the selection when the RadEditor's contentArea loses its focus. To workaround this, you can get and store the RadEditor's range. You can get it on OnClientSelectionChange event and restore it before paste.

Here is an example:
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad" OnClientSelectionChange="OnClientSelectionChange">
    <Content>
        <p>Some test content</p>
    </Content>
</telerik:RadEditor>
 
<telerik:RadButton ID="RadButton_InsertHtml" runat="server" Text="Insert HTML" OnClientClicked="Button_OnClick" AutoPostBack="false" />
 
<script>
    var editor, range;
    function OnClientLoad(sender, args) {
        editor = sender;
    }
 
    function OnClientSelectionChange(sender, args) {
        range = editor.getSelection().getRange(true);
    }
 
    function Button_OnClick() {
        if (range) {
            editor.getSelection().selectRange(range);
        }
        editor.pasteHtml("Inserted Text");
    }
</script>


Regards,
Nikolay
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Dinakaran
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Marco
Top achievements
Rank 1
Share this question
or