radcombobox with IsEditable Property search with two keyword like using FilteringBehavior in radautocompletebox

5 posts, 0 answers
  1. ابو
    ابو avatar
    14 posts
    Member since:
    Oct 2015

    Posted 09 Nov Link to this post

    hi my friends

    I wanna to use radcombobox in editable mode to search with two key words

    by employee id and employee name

    for each key word I wanna to show employee name in radcombobox

    example:

    table from database

    id             name

    ----           ---------

    10            jack

    20            ali

    30            dany

    search by employee id like picture 1.

    search by employee name like picture 2.

     

  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 11 Nov Link to this post

    Hello,

    RadComboBox provides support for implementing a custom Filtering Behavior. For more details, please check the following article from our help documentation:
    http://docs.telerik.com/devtools/wpf/controls/radcombobox/features/filteringbehavior

    Hope this helps.

    Regards,
    Kalin
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
  4. ابو
    ابو avatar
    14 posts
    Member since:
    Oct 2015

    Posted 15 Nov in reply to Kalin Link to this post

    OK , but how I can use it in edit mode to search with employee id or employee name
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 17 Nov Link to this post

    Hi,

    This can be achieved by overriding the FindMatchingIndexes method and implement a logic that filters the items depending on the input. Check the following snippet:


    public class CustomFilteringBehavior : ComboBoxFilteringBehavior
    {
        public override List<int> FindMatchingIndexes(string text)
        {
            int id = -1;
            // if the input is number select the items with matching id
            if (int.TryParse(text, out id))
            {
                return this.ComboBox.Items.OfType<DataItem>().Where(i => i.Id == id).Select(i => this.ComboBox.Items.IndexOf(i)).ToList();
            }
     
            // if the input is string select the items with matching name
            return this.ComboBox.Items.OfType<DataItem>().Where(i => i.Name.ToLowerInvariant().Contains(text.ToLowerInvariant())).Select(i => this.ComboBox.Items.IndexOf(i)).ToList();
        }
    }

    Hope this helps.

    Regards,
    Kalin
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
  6. ابو
    ابو avatar
    14 posts
    Member since:
    Oct 2015

    Posted 27 Nov in reply to Kalin Link to this post

    thanks

    but I have error in Id (i.Id)

    Where(i => i.Id == id)

    error: 'DataItem' dose not contain a definition for 'Id' .......

Back to Top
UI for WPF is Visual Studio 2017 Ready