Hi there
I have two perfectly working RadComboBoxes - one is single column, the other is a multi-column (using itemtemplate). Both use LoadOnDemand (ItemsRequested event).
I noticed that the single column combobox highlights text as the user types, but the same does not happen for the multi-column combobox. I've set HighlightTemplatedItems="true" but this of course only affects the highlighting of the row, not individual letters.
I checked the Q3 2010 demos on my system and they replicate the issue I am having.
But then I noticed that the demo on this site has a working version, but you have not posted the code for it on the page. For example, type in "ca" in the product combobox and the "Ca" highlights on the two matching items.
http://demos.telerik.com/aspnet-ajax/combobox/examples/overview/defaultcs.aspx
Are you able to post the code for the example on the page above so I can see what I may be missing? Cheers :)
The code i use is as follows.
Markup
<!-- Multi-column RadComboBox -->
<!-- HighlightTemplatedItems property highlights the item row (created by itemtemplate) on mouse hover -->
<!-- OnClientKeyPressing event opens combobox drop down when text is being typed -->
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
AutoPostBack
=
"true"
Height
=
"170px"
Width
=
"580px"
HighlightTemplatedItems
=
"true"
EnableLoadOnDemand
=
"True"
Filter
=
"Contains"
NoWrap
=
"True"
ShowMoreResultsBox
=
"True"
OnItemsRequested
=
"RadComboBox1_ItemsRequested"
OnSelectedIndexChanged
=
"RadComboBox1_SelectedIndexChanged"
OnClientKeyPressing
=
"(function(sender, e) { if (!sender.get_dropDownVisible()) sender.showDropDown(); })"
>
<
HeaderTemplate
>
<
ul
>
<
li
class
=
"col1"
>Text Property</
li
>
<
li
class
=
"col2"
>Value Property</
li
>
<
li
class
=
"col3"
>InstNumber Attribute</
li
>
</
ul
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
ul
>
<
li
class
=
"col1"
>
<%# DataBinder.Eval(Container, "Text")%></
li
>
<
li
class
=
"col2"
>
<%# DataBinder.Eval(Container, "Value")%></
li
>
<
li
class
=
"col3"
>
<%# DataBinder.Eval(Container, "Attributes['InstNumber']")%></
li
>
</
ul
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
C#
protected
void
RadComboBox1_ItemsRequested(
object
o, RadComboBoxItemsRequestedEventArgs e)
{
int
recordCount = 0;
int
itemsPerRequest = 100;
// how many items to list in combobox
int
itemOffset = e.NumberOfItems;
int
endOffset = itemOffset + itemsPerRequest;
string
searchValue = e.Text;
// prevent filtering on whitespace
if
(String.IsNullOrWhiteSpace(searchValue))
searchValue =
null
;
// get data from database
InstitutesData records =
new
InstitutesData();
records = records.ReadRecordsComboBox(searchValue);
// if there are records
if
(records !=
null
)
{
// get count
recordCount = records.Count;
// add INST_NO to front of INST_NAME (custom functionality)
for
(
int
i = 0; i < recordCount; i++)
{
records[i].INST_NAME = records[i].INST_NO.ToString() +
" - "
+ records[i].INST_NAME;
}
}
// ensure offset isnt greater than the number of records available
if
(endOffset > recordCount)
endOffset = recordCount;
// bind data to combobox
RadComboBox1.DataTextField =
"INST_NAME"
;
// "123 - Number One School"
RadComboBox1.DataValueField =
"INST_NO"
;
// 123
RadComboBox1.DataSource = records;
RadComboBox1.DataBind();
// populate combobox with items within offsets
RadComboBox1.Items.Clear();
for
(
int
i = itemOffset; i < endOffset; i++)
{
RadComboBoxItem item =
new
RadComboBoxItem();
item.Text = records[i].INST_NAME;
item.Value = records[i].INST_NO.ToString();
item.Attributes.Add(
"InstNumber"
, records[i].INST_NO.ToString());
RadComboBox1.Items.Add(item);
item.DataBind();
}
// display record count information in results box
if
(recordCount > 0)
{
e.Message = String.Format(
"Items <b>0</b>-<b>{0}</b> out of <b>{1}</b>"
, endOffset, recordCount);
}
else
{
// display 'no data in database' message
if
(String.IsNullOrEmpty(searchValue))
e.Message =
"No data"
;
// display 'no matches in database' message
else
e.Message =
"No matches"
;
}
}
protected
void
RadComboBox1_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
// do something when the selected index is changed
string
selectedValue = e.Value;
}