Insert text into rad editor at cursor position.

3 posts, 1 answers
  1. Danny
    Danny avatar
    25 posts
    Member since:
    Jan 2009

    Posted 02 Jun 2012 Link to this post

    I have setup a page with rad editor. I have a related a customer combo box on the menu on the rad editor. I have not put any code or anything being the custom dropdow box. Basically, what I want to do is, any time an item is selected from the combo, the contents of the combo are inserted into the rad editor. The important part is, the contents are inserted into the place of the cursor.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jun 2012 Link to this post

    Hi Danny,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting" >
                <Tools>
                    <telerik:EditorToolGroup >
                        <telerik:EditorSplitButton Name="addData" Text="addData">
                            <telerik:EditorDropDownItem Name="one" Value="one" />
                               .................................................
                        </telerik:EditorSplitButton>
                    </telerik:EditorToolGroup>
                </Tools>
     </telerik:RadEditor>

    JS:
    <script type="text/javascript" >
            function OnClientCommandExecuting(sender, args)
            {
                var val = args.get_value();
                var name = args.get_name();
                if (name == "addData")
                {
                    sender.pasteHtml(val);
                    args.set_cancel(true);
                }
            }
     </script>

    Thanks,
    Shinu.
  3. Danny
    Danny avatar
    25 posts
    Member since:
    Jan 2009

    Posted 03 Jul 2012 Link to this post

    Thank you very much. This works great!
Back to Top