
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

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
>
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>"
));
}
}
<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

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

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.

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

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.