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

show default item with Filter and LoadOnDemand

1 Answer 39 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 15 May 2010, 03:49 AM
I'm using LoadOnDemand with a WebService to load items from a database. I am also using the Filter = "Contains" property, not to filter the results (my web service does that), but to highlight the search term in the result set. With "Contains" the text may be anywhere in the item, so it is a visual cue to see where it matched.

Here is my problem: If someone types in "xyz" and no filter items match, it returns an empty set. I would like to show a message that says "No matches found". One solution I tried was to detect the fact that no items were being returned in the web service, and then inserting a dummy item with the text "No matches found". The problem is this gets filtered out by the control because "No matches found" does not contain "xyz".

I thought of two solutions, but each has me stumped:
1. Using OnClientItemsRequested, if the result set is 0 items, then turn off filtering so that the message will show. The turn filtering back on next time OnClientItemsRequested is called. I can't seem to control the filter property with javascript though.
2. Use the RadComboBoxData.Message property to say "No matches found", but this doesn't appear when I send my result back from the web service. I don't know if I'm doing it wrong, or if the filter is hiding it, or if that only works with virtual scrolling.

I am also open to other solutions. I would rather not change the user's text input however. For example, if they type "xyz" and there are no matches, I don't want to clear their "xyz" entry and show the message in the box. Maybe they made a typo and just need to backspace and correct it. If we clear it, I think it will be confusing.

I look forward to your advice! Thank you.

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 19 May 2010, 06:19 PM
Hi Joel,

Let me recommend you to use the second approach that you mention - if there are no matching items found after a request is performed - set the RadComboBoxData.Message property to “No results found” or similar text.
I believe that this approach will be much easier for you to implement than the first one that you describe.

I made a sample page and webservice for you – please find them attached.
Please let me know if this was helpful.

All the best,
Kalina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
Joel
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or