Filtering several columns

4 posts, 1 answers
  1. Dennis
    Dennis avatar
    7 posts
    Member since:
    Aug 2011

    Posted 03 Nov 2011 Link to this post

    Hi there,

    perhaps it is a stupid question, but I don't get it to work and I found nothing in the web.
    I have a multicolumncombobox with 3 columns. I want to add a filter, which searches in all 3 columns and displays all results found in one of the 3 columns.
    First I found the filterdescriptor class. That worked fine, but it displays only results, which are found in all 3 columns and not in one of them.
    Then I tried to get it work with the compositefilterdescriptor. And that does not work for me. Perhaps someone has a hint. Here is my code:

    Telerik.WinControls.Data.CompositeFilterDescriptor compositeDescriptor = new Telerik.WinControls.Data.CompositeFilterDescriptor();
    compositeDescriptor.LogicalOperator = Telerik.WinControls.Data.FilterLogicalOperator.Or;
    compositeDescriptor.FilterDescriptors.Add(new Telerik.WinControls.Data.FilterDescriptor("productNo", Telerik.WinControls.Data.FilterOperator.Contains, cbo_ProductMultiColumn.Text.ToString()));
    compositeDescriptor.FilterDescriptors.Add(new Telerik.WinControls.Data.FilterDescriptor("productSearchName", Telerik.WinControls.Data.FilterOperator.Contains, cbo_ProductMultiColumn.Text.ToString()));
    compositeDescriptor.FilterDescriptors.Add(new Telerik.WinControls.Data.FilterDescriptor("productName", Telerik.WinControls.Data.FilterOperator.Contains, cbo_ProductMultiColumn.Text.ToString()));
    compositeDescriptor.IsFilterEditor = true;
    this.cbo_ProductMultiColumn.EditorControl.FilterDescriptors.Add(compositeDescriptor);

    Sorry, if it is a stupid question. I'm still a beginner. :-)
  2. Dennis
    Dennis avatar
    7 posts
    Member since:
    Aug 2011

    Posted 03 Nov 2011 Link to this post

    I forgot to ask, if it is possible in general to add the compositefilterdescriptor to the mutlicolumncombobox. Is it?
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 07 Nov 2011 Link to this post

    Hello Dennis,

    You should change the LogicalOperator property of the FilterDescriptorCollection:

    this.radMultiColumnComboBox1.AutoFilter = true;
     
    FilterDescriptor idFd = new FilterDescriptor("ID", FilterOperator.Contains, null);
    this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(idFd);
     
    FilterDescriptor companyNameFd = new FilterDescriptor("CompanyName", FilterOperator.Contains, null);
    this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(companyNameFd);
     
    this.radMultiColumnComboBox1.EditorControl.FilterDescriptors.LogicalOperator = FilterLogicalOperator.Or;

    I hope this helps.

    Regards,
    Svett
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  5. Dennis
    Dennis avatar
    7 posts
    Member since:
    Aug 2011

    Posted 14 Nov 2011 Link to this post

    Thank you. That worked fine.
Back to Top