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

Paste the Content at the Cursor point

5 Answers 82 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 20 Feb 2013, 06:43 AM
Hi,
I am ussing radeditor with custom radcombobox in it. when i add the content from combobox to rad editor it paste the value on top of the content but i need to be Paste at the cursor point.



Thanks

5 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Feb 2013, 06:54 AM
Hi Dhamodaran

When the user clicks on the combobox control the selection in the editor's content area is lost. The code below demonstrates how to make all comboboxes' items unselectable to prevent selection lost in RadEditor's content area. 
In addition the getSelectedItemValue function is attached to the OnClientSelectedIndexChanged event of RadCombobox and pastes the selected item value at cursor position in the editor when the user selects a combobox item:
Try the following code snippet and let me know your concern.
aspx:
<telerik:radeditor runat="server" ID="RadEditor1" Content="test mest"></telerik:radeditor>
<div style="padding: 15px 0 0 0;font-family:Arial;font-size:14px;">
    RadComboBox with static items:
    <telerik:RadComboBox OnClientSelectedIndexChanged="getSelectedItemValue" OnClientLoad="OnClientLoad" ID="RadCombobox1" runat="server">
        <Items>
            <telerik:RadComboBoxItem Text="Item1" Value="<strong>Item 1</strong>" />
            <telerik:RadComboBoxItem Text="Item2" Value="<strong>Item 2</strong>" />
            <telerik:RadComboBoxItem Text="Item3" Value="<strong>Item 3</strong>" />
        </Items>
    </telerik:RadComboBox>
</div>
<div style="padding: 15px 0 0 0;font-family:Arial;font-size:14px;">
    RadComboBox with Load-On-Demand:
    <telerik:RadComboBox OnClientSelectedIndexChanged="getSelectedItemValue" OnClientItemsRequested="OnClientItemsRequested" OnClientLoad="OnClientLoad" ID="RadCombobox2" runat="server"
        OnItemsRequested="RadCombobox2_ItemsRequested" EnableLoadOnDemand="true"></telerik:RadComboBox>
</div>
C#:
using Telerik.Web.UI;
       
protected void RadCombobox2_ItemsRequested(object o, Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs e)
{
        for (int i = 0; i < 10; i++)
        {
            RadCombobox2.Items.Add(new RadComboBoxItem("Item" + i.ToString(), "<strong>Item " + i.ToString() + "</strong>"));
        }
}
JS:
<script type="text/javascript">
function OnClientLoad(combobox, args)
{
    makeUnselectable(combobox.get_element());
}
   
function OnClientItemsRequested(combobox, args)
{
    $telerik.$("*", combobox.get_dropDownElement()).attr("unselectable", "on");
}
       
//Make all combobox items unselectable to prevent selection in editor being lost
function makeUnselectable(element)
{
    $telerik.$("*", element).attr("unselectable", "on");
}
     
function getSelectedItemValue(combobox, args)
{
  var value = combobox.get_value();
  //alert("The selected combobox value is: " + value);
  //get a reference to RadEditor client object
  //and paste the selected combobox item content in it
  var editor = $find("<%=RadEditor1.ClientID%>");
  editor.pasteHtml(value);
</script>

Thanks
Princy
0
Dhamodharan
Top achievements
Rank 1
answered on 20 Feb 2013, 07:10 AM

Hi Princy,
                        I am using the Same code -  editor.pasteHtml(value) . Its works good, content is pasted on the top of the Existing content. I want the content to paste on the Cursor point.








Thanks




0
Accepted
Princy
Top achievements
Rank 2
answered on 21 Feb 2013, 06:55 AM
Hi Dhamodharan

Take a look at the following Knowledge Base Article of Telerik which explains your same issue for more information and let me know your concern.
Pasting content from RadComboBox item in RadEditor at cursor position

Thanks
Princy.
0
Dhamodharan
Top achievements
Rank 1
answered on 21 Feb 2013, 09:27 AM
Hi Princy,

  Your both  code works. I have done the mistake in calling the  OnClientItemsRequested function in the ClientItemsRequesting event. Now it works perfectly


 



Thanks
0
Frank
Top achievements
Rank 1
answered on 07 Mar 2013, 10:20 AM

Hi Princy,

Following this thread we achieved having the RadComboBox visible with its items. Now we want people to have the ability to type into it to find their item quicker. We set the HighlightTemplatedItems="true" and Filter="Contains".

Problem now is you can’t select the item to start typing. You can press delete to remove the current selected item and start typing, but then it inserts the selected item again at the beginning of the RadEditor.

Any idea how to solve this so users can use the type-option and search within the RadComboBox ?


Yours,
Frank.
Tags
Editor
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dhamodharan
Top achievements
Rank 1
Frank
Top achievements
Rank 1
Share this question
or