Records are not displaying while setting MatchMode=Anywhere

5 posts, 0 answers
  1. John
    John avatar
    18 posts
    Member since:
    Jul 2009

    Posted 23 Jul 2010 Link to this post

    <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 



  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 25 Jul 2010 Link to this post

    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
  3. John
    John avatar
    18 posts
    Member since:
    Jul 2009

    Posted 26 Jul 2010 Link to this post


    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.



     
  4. John
    John avatar
    18 posts
    Member since:
    Jul 2009

    Posted 29 Jul 2010 Link to this post

    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
  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 29 Jul 2010 Link to this post

    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
Back to Top