Filter and Sort

Posted by: silkkeng-fp on 8 September 2017, 1:51 pm EST

  • Posted 8 September 2017, 1:51 pm EST

    Hi Scott,

    We are currently using build 4.0.2003.2005 and need help with Filter and Sort.

    Steps:

    1. Set the Filter

    Column.AllowAutoFilter = True
     

    2. Set the Sort

    Column.AllowAutoSort = True

    3. Reset Sort

    SpreadSheet.Models.ResetViewRowIndexes()

     

    The problem :

    After reset sort and filter is still on, the list appears in the filter is not longer taking account of the filter criteria.

    E.g.

    There are few items

    Row Index        Item Data
    0            a

    1            b

    2            c

    3            b

    4            a

     

    Now, Filter by "b"

    It shows:

    Row Index        Item Data
    1            b

    3            b

     

    Then, Sort Asc

    It still shows:

    Row Index        Item Data
    2            b

    3            b

     

    Then Reset Sort (ResetViewRowIndexes), and you may notice the the list will be appear as

    Row Index        Item Data
    2            c

    3            b

     

    instead of

    b

    b

     

    Question :

    Is there a way to reset the sort while still maintain the filter item? OR I shouldn't use the ResetRowViewIndexes?

     

    Thank you

     

    Regards,

    David


    2010/05/Reset Column Sort and Filter.rar
  • Replied 8 September 2017, 1:51 pm EST

    Hello Daivd,

    Regarding the behavior, when you apply filtering on a particular column then as per the filtering criteria the underlying(filtered) rows gets hidden, therefore you are not seeing any difference in the RowIndex upon resetting the RowIndexes using ResetRowViewIndexes. You may refer to  earlier  thread for more information on this.

    Thanks

  • Replied 8 September 2017, 1:51 pm EST

    Hello,


    This behavior is expected as Suresh stated. However I am going to report this to the development team to see about changing the behavior to reassign the filter after resetting the ViewRowIndices. For now, you can add code to reapply the filter after restting the row indices.


    FpSpread1.Sheets(0).Models.ResetViewRowIndexes()


    Dim filterColumnIndexes() As Integer = FpSpread1.Sheets(0).RowFilter.GetFilteredColumnIndexes()


    For i As Integer = 0 To filterColumnIndexes.Length - 1


    Dim modelColumn As Integer = filterColumnIndexes(i)


    Dim filterBy As String = FpSpread1.Sheets(0).RowFilter.GetColumnFilterBy(modelColumn)


    If Not (filterBy Is Nothing) And filterBy.Length > 0 Then


    FpSpread1.Sheets(0).AutoFilterColumn(FpSpread1.Sheets(0).GetViewColumnFromModelColumn(modelColumn), filterBy, 0)


    End If


    Next i

Need extra support?

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

Learn More

Forum Channels