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

Load On Demand No Results Found

6 Answers 203 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 13 Dec 2010, 10:22 AM
Is there a way the RadComboBox can display a 'No Results Found' message in the dropdown when a load on demand request returns no matches?

Currently there's a pause while the database is queried and then the dropdown remains empty, its not very user friendly.

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Dec 2010, 11:28 AM
Hi Rick,


Set the "ShowMoreResultsBox" property of RadComboBox to "True" which in turn shows "No matches" if there are not items in dropdown.

Another option is adding an item with Text "No items found" or similar when there are no items in Item collection.
Add/Remove/Disable items (demo)


-Shinu.
0
Rick
Top achievements
Rank 1
answered on 13 Dec 2010, 12:02 PM
Thanks Shinu but that doesn't quite work for me since my RadComboBox has multiple columns

The first method doesn't work and the second would just look weird as there are table headings.
0
Cori
Top achievements
Rank 2
answered on 13 Dec 2010, 02:16 PM
Hello Rick,

How does setting ShowMoreResultsBox="true" not work? Are you setting the text in your ItemsRequested event? If not, that is how this technique works when not using AutomaticLoadOnDemand.

You can see it done in this demo: http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx

I hope that helps.
0
Rick
Top achievements
Rank 1
answered on 14 Dec 2010, 12:06 PM
It doesn't work because there is no message saying "No results found". There is only the Show More Results arrow. See attached image.

The code is as follows:

<telerik:RadComboBox ID="rcbInvoiceAddresses"         
        SkinID="custom"                               
        AllowCustomText="true"       
        ShowMoreResultsBox="true"                          
        EmptyMessage="Please select..."
        HighlightTemplatedItems="true"
        DataValueField="AddressNo"                                                                                       
        DataTextField="Name"   
        EnableLoadOnDemand="True"
        AutoPostback="true"                                       
        DropDownWidth="600px"
        Width="200px"
        OffsetX="-400"                               
        OnItemsRequested="rcbInvoiceAddresses_ItemsRequested"    
        OnSelectedIndexChanged="rcbInvoiceAddresses_SelectedIndexChanged"                                                                                                                          
        runat="server">       
                                         
        <HeaderTemplate>
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <td style="width: 170px;">Name</td>
                    <td style="width: 320px;">Address</td>
                    <td>Type</td>
                </tr>
            </table>
        </HeaderTemplate>
 
        <ItemTemplate>
            <table cellspacing="0" cellpadding="0">
                <tr>
                    <td style="width: 150px; padding-right: 20px;"><%# Eval("Name")%></td>                                                   
                    <td style="width: 300px; padding-right: 20px;"><%# Eval("_AddressSummary")%></td>                                                                                                   
                    <td><%# Eval("FK_AddressType")%></td>  
                </tr>
            </table>
        </ItemTemplate>
</telerik:RadComboBox>


0
Rick
Top achievements
Rank 1
answered on 14 Dec 2010, 12:17 PM
Oh sorry I see what you mean, you need to set the "e.Message" property if no results are found.

OK I've done that and this is now working as you say, but I don't actually want the 'Show More Results' functionality - this is now just keeps appending all values to the dropdown. This should just be a dropdown showing ~ 50 rows which I don't want to retrieve until the user requests them - I don't need to fetch then incrementally.

So - empty drop down, load (fully) on demand, and show no results message.

This is my code at present in the ItemsRequested event:
rcbDeliveryAddresses.Items.Clear();
rcbDeliveryAddresses.DataSource = (object)addresses;           
rcbDeliveryAddresses.DataBind();
if (addresses.Count == 0) e.Message = "No Results Found";
0
Rick
Top achievements
Rank 1
answered on 14 Dec 2010, 12:22 PM
Done! I just had to set the e.EndOfItems = true

Cheers
Tags
ComboBox
Asked by
Rick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rick
Top achievements
Rank 1
Cori
Top achievements
Rank 2
Share this question
or