Working with Filters

Posted by: mark71 on 8 September 2017, 4:35 am EST

  • Posted 8 September 2017, 4:35 am EST

    Hi


    I am trying to extract the current filters a user has set on the grid so that I can programmatically replace them at a later point.


    Is this possible? I hope you can help, as I am getting a bit lost in the documentation and while I have managed to identify when a column is filtered using the '<FONT size=1>ActiveSheet.RowFilter.IsFiltered' </FONT>property that is about all I have achieved.


    Regards


    Mark


     

  • Replied 8 September 2017, 4:35 am EST

    Mark -

    You should be able to use the GetFilterColumnDefinition for the columns.

  • Replied 8 September 2017, 4:35 am EST

    Mark -

    I want to make sure I am understanding you correctly.  You want to return the value from the list that the user selected?  Is that correct?

  • Replied 8 September 2017, 4:35 am EST

    You can use the AutoFilteredColumn event and check the FilterString from ther.
  • Replied 8 September 2017, 4:35 am EST

    Hi BobM,


    Yep, that is the string information I need, so now I can store the filter choices as they are made using the AutoFilteredColumn event.


    Now I need to re-apply these filter choices to the grid at a later time, for instance if they close and re-open the application.


    Is this possible?


    Regards


    Mark

  • Replied 8 September 2017, 4:35 am EST

    Mark,


    There is an AutoFilterColumn method you can use to implement this.

  • Replied 8 September 2017, 4:35 am EST

    Hi BobM,


    Thanks for responding.


    I did see this function but could not find any useful information there.


    If I have 5 columns in my grid and filter on column 2 by selecting a value from the drop down list then the IsFiltered(2) property = True.


    But when I use the GetFilterColumnDefinition(2) it returns the following (which is identical for all columns)

    <FONT size=1>
    <BLOCKQUOTE>

    ?alertspread.Sheets(0).RowFilter.GetFilterColumnDefinition(2)


    {FarPoint.Win.Spread.FilterColumnDefinition}


    CanSerializeXml: True


    ColumnIndex: 2


    Filters: {FarPoint.Win.Spread.FilterItemCollection}


    ListBehavior: Default {1031}

    </BLOCKQUOTE>

    <FONT size=2>And the 'Filters' FilterItemCollection contains:</FONT>

    <FONT size=1><FONT size=1>
    <BLOCKQUOTE>

    ?alertspread.Sheets(0).RowFilter.GetFilterColumnDefinition(2).Filters(0)


    </FONT>{FarPoint.Win.Spread.DefaultFilterItem}


    FarPoint.Win.Spread.DefaultFilterItem: {FarPoint.Win.Spread.DefaultFilterItem}


    DisplayAtTopOfList: True


    DisplayName: "Default Filter"

    </BLOCKQUOTE></FONT>

    <FONT size=2>Am I missing something obvious? I was hoping to see the Filter text, which is set to "N/A", which I could store and then programmatically put this into the filter at a later point.</FONT>


    <FONT size=2>Hope that makes sense.</FONT>


    <FONT size=2>P.S. I am using v2.5.2015.2005 of Spread, not sure if that makes a difference.</FONT>


    <FONT size=2>Regards</FONT>


    <FONT size=2>Mark</FONT>

    </FONT>
  • Replied 8 September 2017, 4:35 am EST

    Hi BobM & Scott,


    Thanks for your help, it is all making sense now.


    Regards


    Mark

Need extra support?

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

Learn More

Forum Channels