How to stop filter refreshing after a cell changed

Posted by: projectik-fp on 8 September 2017, 2:04 pm EST

  • Posted 8 September 2017, 2:04 pm EST

    I want to know how i can stop the autofilter from refreshing after a cell change.


    ex.: If I filter col1 on blank and I put a value on a row in col1, this row desappeared. It's very anoying.


    I want to use the filter like excel (without autorefresh)
    i'm using v4.0.3510


    Thanks

  • Replied 8 September 2017, 2:04 pm EST

    You can use code to disconnect the row filter from the Changed event for the data model:

        FpSpread1_Sheet1.Columns(0).AllowAutoFilter = True
        Dim hideRowFilter As FarPoint.Win.Spread.HideRowFilter = CType(FpSpread1_Sheet1.RowFilter, FarPoint.Win.Spread.HideRowFilter)
        Dim dataModel As FarPoint.Win.Spread.Model.BaseSheetDataModel = CType(FpSpread1_Sheet1.Models.Data, FarPoint.Win.Spread.Model.BaseSheetDataModel)
        RemoveHandler dataModel.Changed, AddressOf hideRowFilter.OnDataModelChanged

    That will prevent the filter from seeing changes to the data model, and require that the user explicitly filter the column again to update it.

    Here is some better code (more general):

        Dim rowFilter As FarPoint.Win.Spread.DefaultRowFilter = CType(FpSpread1_Sheet1.RowFilter, FarPoint.Win.Spread.DefaultRowFilter)
        Dim dataModel As FarPoint.Win.Spread.Model.BaseSheetDataModel = CType(FpSpread1_Sheet1.Models.Data, FarPoint.Win.Spread.Model.BaseSheetDataModel)
        RemoveHandler dataModel.Changed, AddressOf rowFilter.OnDataModelChanged
     

  • Replied 8 September 2017, 2:04 pm EST

    Gina, I have more than 6000 rows, style are useless for me
  • Replied 8 September 2017, 2:04 pm EST

    Thanks seanl


    It's work great! Big Smile

  • Replied 8 September 2017, 2:04 pm EST

    Seanl, I've just realized that it's work only when I'm  typing data. When I paste a value, the filters was refreshed


    Confused


     

  • Replied 8 September 2017, 2:04 pm EST

    You prefer to use a hide row filter rather than a style row filter?  Thanks.
  • Replied 8 September 2017, 2:04 pm EST

    Yes, the code in SheetView.ClipboardPaste will re-filter each column that is filtered after the values are pasted by calling the AutoFilterColumn method with the current filter string.  You can disable automatic handling of the clipboard shortcut keys by setting FpSpread.AutoClipboard = false, but you would need to write code to handle the pasting.  You can use SheetView.SetClipSpecial to implement custom paste handling (that method will not affect the filters).
Need extra support?

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

Learn More

Forum Channels