Adding custom filters to match default filters

Posted by: andrewl-fp on 8 September 2017, 1:21 pm EST

  • Posted 8 September 2017, 1:21 pm EST

    The way the default filters work, every time a new value is added in a column, a new filter appears to allow filtering based on that value. What I would like to do is every time one of these filters is added, I want one of my custom filters to be added as well for that same item. The goal is to be able to filter not only for matching values, but similar values as well. I have the custom filter defined and have successfully added a single instance of it. Now I want to dynamically add instances whenever needed.

    I tried handling the SheetView.RowFilter.ColumnDefinitions.Changed event, but I had a hard time getting around the StackOverflows since every time a ColumnDefinition is added, including my own, it fires the event twice. I tried using a flag to determine whether to handle the event or not, but that only stops one of the events. I suppose I could throw a second flag in there or possibly refine the logic behind the flag, but that's starting to be more work than I want to put into this functionality. Is there an easier way?

  • Replied 8 September 2017, 1:21 pm EST

    Andrew -

    Have you tried using something like the Changed event for the DataModel instead?  If that doesn't work then I can't think of another event in which you would be able to do what you want.

  • Replied 8 September 2017, 1:21 pm EST

    I probably could get that to work, although it's a bit too inefficient.
    The data model is getting updated constantly (I have it displaying log
    events. The log events contain a category and any number of
    sub-categories and I'm hoping to be able to filter on a category and
    have it also show the appropriate sub-categories), but only a few of
    those changes are going to trigger the addition of new filters. As it's
    only meant to display an event log, I'd rather not waste the processing
    time that could be better used in the rest of the application. The
    Changed event for the ColumnDefinitions would work nicely except that
    it fires twice for every change, making it a little harder to determine
    whether I need to be adding the new filter or not. While not impossible
    by any means, it's just a little too complicated for the purpose it
    serves. I was kind of hoping for a one or two line solution, but it's
    not looking like it'll be quite that easy.
Need extra support?

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

Learn More

Forum Channels