Hello,
I'm using a combobox to let the user search items.
The thing is that I want the text the user entered be highlighted in the different items but without using the Filter property.
The filtering for my query is done in the server. I want the text be highlighted if there are corresponding results but continue to display all the items returned from the server even if there is no match in the text.
The thing is that my users are allowed to search items on criteria that may not be displayed in the comboboxes item list.
What I mean for example, is that I can have the following items to lookup for:
index, name
0, john
1, jeanne
2, jo
the combobox only shows the names of the people.
when I search for 'jo' the CBB should display two items, jo and john and higlight the 'jo' part of both items.
But now when I search for '2', it should display one item 'jo' without any highligh in that case...
How can this be done ?
Here is the code I use:
You can see that the user can search by CodePDV even if CodePDV is not displayed in the CBB.
Thank you for you help,
John.
I'm using a combobox to let the user search items.
The thing is that I want the text the user entered be highlighted in the different items but without using the Filter property.
The filtering for my query is done in the server. I want the text be highlighted if there are corresponding results but continue to display all the items returned from the server even if there is no match in the text.
The thing is that my users are allowed to search items on criteria that may not be displayed in the comboboxes item list.
What I mean for example, is that I can have the following items to lookup for:
index, name
0, john
1, jeanne
2, jo
the combobox only shows the names of the people.
when I search for 'jo' the CBB should display two items, jo and john and higlight the 'jo' part of both items.
But now when I search for '2', it should display one item 'jo' without any highligh in that case...
How can this be done ?
Here is the code I use:
<
telerik:RadComboBox
ID
=
"cbbMagasin"
runat
=
"server"
Width
=
"450px"
Height
=
"150px"
ClientIDMode
=
"Static"
Filter
=
"Contains"
EmptyMessage
=
"Choisir un magasin..."
EnableLoadOnDemand
=
"True"
ShowMoreResultsBox
=
"true"
ItemsPerRequest
=
"20"
EnableVirtualScrolling
=
"true"
OnClientDropDownOpening
=
"cbbMagasin_DropDownOpening"
OnItemsRequested
=
"cbbMagasin_ItemsRequested"
LoadingMessage
=
"Chargement..."
Localization-NoMatches
=
"Aucune correspondance"
MarkFirstMatch
=
"True"
>
</
telerik:RadComboBox
>
protected
void
cbbMagasin_ItemsRequested(
object
sender, RadComboBoxItemsRequestedEventArgs e)
{
RadComboBox cbbMagasin = sender
as
RadComboBox;
cbbMagasin.Items.Clear();
var magasins = DbContext.Magasins.Where(p => p.Ville.Contains(e.Text) || p.Enseigne.Contains(e.Text) || p.CodePDV.Contains(e.Text)).OrderBy(p => p.Enseigne).ThenBy(p => p.Ville);
foreach
(Magasin m
in
magasins)
{
RadComboBoxItem item =
new
RadComboBoxItem();
item.Text = NamingHelpers.MagasinLabel(m);
item.Value = m.MagasinID.ToString();
cbbMagasin.Items.Add(item);
item.DataBind();
}
}
You can see that the user can search by CodePDV even if CodePDV is not displayed in the CBB.
Thank you for you help,
John.