Set programmatically filters break the sorting functionality

Posted by: davide.vago on 29 August 2019, 8:30 pm EST

    • Post Options:
    • Link

    Posted 29 August 2019, 8:30 pm EST

    Good morning/evening

    I’m reaching you out as I’ve tried to use the HideRowFilter functionality to setup a filtering system within a sheet

    my code is something like this:

    
    const totalRows = window.spreadSheet.activeSheet.getRowCount()
    const totalCols = window.spreadSheet.activeSheet.getColumnCount()
    const rowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(
      new GC.Spread.Sheets.Range(1, 0, totalRows, totalCols),
    )
    
    window.spreadSheet.activeSheet.rowFilter(rowFilter)
    rowFilter.filterButtonVisible(0, true)
    
    

    The output displays correctly the small triangle on top of the cells of the first row, the filters are working correctly but whenever I click on Sort Ascending/Descending it doesn’t trigger anything

    I’m wondering if I’m missing some configuration, the documentation for the Filters is a bit mixed, there are few methods that are deprecated and I can’t find valuable examples

    Thanks in advance for your support

  • Posted 1 September 2019, 6:12 pm EST

    Hi Davide,

    The issue in the code snippet is that the Range passed to the HideRowFilter is an invalid range, You have passed the range as starting from 1st row and rowCount = total rows, whereas rowCount should be totalRows - 1 (since we are starting from row 1). Fixing the row count should fix the issue. Please refer to the following code snippet and let us know if the issue persists for you,

    const totalRows = window.spreadSheet.activeSheet.getRowCount()
    const totalCols = window.spreadSheet.activeSheet.getColumnCount()
    const rowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(
      new GC.Spread.Sheets.Range(1, 0, totalRows - 1, totalCols),
    )
    
    window.spreadSheet.activeSheet.rowFilter(rowFilter)
    rowFilter.filterButtonVisible(0, true)
    

    Regards

  • Posted 1 September 2019, 9:16 pm EST

    Good morning/afternoon Sharad,

    Thanks for coming back to me with this, the solution does work, I was also triggering the range filter before injecting the datasource so it was behaving incorrectly as by default the range (getRowCount) returns 200 as value if the data is not being applied

Need extra support?

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

Learn More

Forum Channels