Filtering on a combo box column

Posted by: karthiks2 on 8 September 2017, 1:41 pm EST

  • Posted 8 September 2017, 1:41 pm EST

    I need a column filter on a Combo Box (dropdown list) column. Just having the autofilter property enabled, does not help.

     Can I achieve this task using just the autofilter property? If not, could anybody plz share the pseudo code for the implementation.

     Thanks.

  • Replied 8 September 2017, 1:41 pm EST

    Hi Scotts,

    What is the best way to add multiple custom Filter items into the filter list?

    Thanks,

  • Replied 8 September 2017, 1:41 pm EST

    Hello,


    The AutoFilter takes data from the particular column of the DataModel (in your case already selected items in the comboboxes) and uses that to fill the AutoFilter list. If you want other items in the list, you would need to create a custom FilterItem to add to the row filter.

  • Replied 8 September 2017, 1:41 pm EST

    Hello Scotts,

    The AutoFilter is not picking the data already selected in the combobox (DataModel).Do you know what the reason for this might be!

    Could you kindly share a small application which uses the custom FilterItem to add an item to the row filter.

    Thanks.

  • Replied 8 September 2017, 1:41 pm EST

    Hello,


    You can check the Value property of the cell in the column that has an item selected from the combobox. The Value returned in these cells should be reflected in the AutoFilter. Here is the code I tested and before making a selection, no items are shown in the Filter. I then make one or more selections in the combobox, and those items show in the filter.


    Dim c As New FarPoint.Win.Spread.CellType.ComboBoxCellType


    c.Items = New String() {"aaa", "bbb", "ccc"}


    FpSpread1.Sheets(0).Columns(1).CellType = c


    FpSpread1.Sheets(0).Columns(1).AllowAutoFilter = True


    You can look at our SpreadWinDemo at the AdvancedFiltering page for code how to add a custom FilterItem to the row filters.

  • Replied 8 September 2017, 1:41 pm EST

    Hello,


    Just like the code I pointed to you added one custom FilterItem class object to the FilterColumnDefinition, you can add as many FilterItem objects as you want to this list.

  • Replied 8 September 2017, 1:41 pm EST

    Thanks scotts. I'm done with my query.
  • Replied 8 September 2017, 1:41 pm EST

    Hi Scotts,

    I have an issue with the custom filter that I developed.

    Issue: I can expand the filter dropdown by clicking on the filter symbol. But I am unable to collapse the filter by clicking on the filter symbol again. To collapse the filter, I need to click on the grid. The filter also gets collapsed on selecting a filter item.

    How do I collapse the filter dropdown by clicking on the filter symbol?

    Description of usage of custom Filter:

    My custom Filter does not contain any values by default. All the filter items are custom items. I have created a Custom Filter class for the same which implements BaseFilterItem class.

    The filtering of the custom Filter, is done in the event AutoFilteredColumn. The filtering needs to be done here as i need multiple parameters for which I could not use the Filter event of the custom class.

    Thanks,
    Karthik

  • Replied 8 September 2017, 1:41 pm EST

    Karthik,


    There is not a public method to get at the list of filtered items to see if it is displayed already and if it is to close it.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels