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

Records are not displaying while setting MatchMode=Anywhere

4 Answers 105 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 Jul 2010, 02:07 PM
<telerik:RadComboBox ID="radComboCustomer" Skin="Sunset" runat="server" Width="50%"
     CssClass="ComboBox" OnClientSelectedIndexChanged="setSelectedCustomerData" EnableLoadOnDemand="true"
   OnItemsRequested="radComboCustomer_ItemsRequested" ShowMoreResultsBox="true"
      EnableVirtualScrolling="true"></telerik:RadComboBox>


 protected void radComboCustomer_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        MIDAS.DAL.CompanyFactory objCustomerFactory = new MIDAS.DAL.CompanyFactory(SessionScope.FactoryScope);

        CompanyCollection allCustomer = new CompanyCollection();
        ICriteria criteria = objCustomerFactory.GetBasicCriteria();
        List<ICriterion> filters = new List<ICriterion>();
       

        if (!string.IsNullOrEmpty(e.Text))
        {
            filters.Add(Restrictions.Like("CompanyName", e.Text, MatchMode.Start));
        }

        
        foreach (ICriterion filter in filters)
        {
            criteria.Add(filter);
        }

        allCustomer = objCustomerFactory.GetAll(criteria, "CompanyName ASC");


        int itemOffset = e.NumberOfItems;
        int endOffset = Math.Min(itemOffset + 10, allCustomer.Count);
        e.EndOfItems = endOffset == allCustomer.Count;

        for (int i = itemOffset; i < endOffset; i++)
        {            
            radComboCustomer.Items.Add(new RadComboBoxItem(allCustomer[i].CompanyName.ToString()  ,                              
            allCustomer[i].CompanyId.ToString()));
        }

        e.Message = GetStatusMessage(endOffset, allCustomer.Count);
    }

 private static string GetStatusMessage(int offset, int total)
    {
        if (total <= 0)
            return "No matches";

        return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
    }


When match mode is with MatchMode.Start then records are displyaing with search and all but when MatchMode.Anywhere
which is property of Nhibernate then records are coming from db and are assigning to Radcombo by RadComboBoxItem
property but i cant see the records in combo.But i can see count properly.
But it works fine with MatchMode.Start 



4 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 25 Jul 2010, 12:40 PM
Hi John,

You are adding the Items to the RadComboBox manually, so please make sure that when MatchMode is Anywhere the following loop actually runs and adds Items:
for (int i = itemOffset; i < endOffset; i++)
{           
    radComboCustomer.Items.Add(new RadComboBoxItem(allCustomer[i].CompanyName.ToString()  ,                             
    allCustomer[i].CompanyId.ToString()));
}

I hope this helps.

Regards,
Simon
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
0
John
Top achievements
Rank 1
answered on 26 Jul 2010, 07:33 AM

for (int i = itemOffset; i < endOffset; i++)
{           
    radComboCustomer.Items.Add(newRadComboBoxItem(allCustomer[i].CompanyName.ToString()  ,                             
    allCustomer[i].CompanyId.ToString()));
}

Oh its basic loop i had putted break point and finally before ending of the funciton ths combo shows all items in 
his list when i am watching in QuickWatch window in debugger mode.
 
While entering cursor in combo it is displyed as open combo with all records
so when typing a letter records bind to combo are not visible to users but
when onblur it automatically closes the empty  record combo and when again focuing on
combo now its showing the searched records.So i think records are present but not visible but
on close and open it shows all records.

please provide me approprite solution.



 
0
John
Top achievements
Rank 1
answered on 29 Jul 2010, 12:49 PM
Just check in codebehind of page if you  have mentioned the below code..
        radCombCustomerName.Filter = Telerik.Web.UI.RadComboBoxFilter.StartsWith;

replace above code with 

 radCombCustomerName.Filter = Telerik.Web.UI.RadComboBoxFilter.Contains ;

       Now its working
0
Simon
Telerik team
answered on 29 Jul 2010, 12:52 PM
Hello John,

So this means that the Filter did not match the MatchMode property, i.e. Items were returned based on a 'contains' filter however, the RadComboBox filtered them on the client with a 'starts with' filter. Is this correct?

Does setting the Filter property of the RCB to 'Contains' fix the issue?

Best wishes,
Simon
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
John
Top achievements
Rank 1
Answers by
Simon
Telerik team
John
Top achievements
Rank 1
Share this question
or