How can I clear the table sheet filter?

Posted by: minhhieu2032000 on 13 March 2025, 2:39 am EST

    • Post Options:
    • Link

    Posted 13 March 2025, 2:39 am EST

    Its my demo:

    https://jscodemine.mescius.io/sample/prsdXl8kfkGe3db8m_JNOw/

    I cannot clear filter when using sheet.rowfilter().Reset()

    Must set the new view to clear filter. How to be able to clear filter of table sheet

  • Posted 13 March 2025, 7:35 am EST

    Hi,

    You are correct that the sheet.rowFilter().reset() method cannot be used to clear filters in a TableSheet. This behavior is expected because a TableSheet is not a standard sheet object; rather, it is a dynamic view that internally utilizes a sheet but does not function as a standalone sheet object. As a result, it does not have access to the rowFilter() method, which is why calling sheet.rowFilter().reset() has no effect.

    Since TableSheet operates as a view, modifying the view itself effectively resets the filter. For more details, you may refer to the following documentation:

    Introduction to TableSheet: https://developer.mescius.com/spreadjs/docs/features/tablesheet

    Sorting and Filtering in TableSheet: https://developer.mescius.com/spreadjs/docs/features/tablesheet/tablesheet-operations/tablesheet-sort-filter

    Sorting and filtering are core functionalities of TableSheet and are implemented by design. If you could share your specific use case, we would be happy to investigate further and suggest a more suitable solution.

    Best regards,

  • Posted 13 March 2025, 10:06 pm EST

    So, I still have to call sheet.setDataView(view) to reset the filter, right?

    I would like to ask if there is any way to know if the Table Sheet is being filtered or not?

  • Posted 17 March 2025, 8:35 am EST - Updated 17 March 2025, 8:40 am EST

    Hi,

    Currently, sorting and filtering programmatically are not supported in TableSheet. This feature is already in our product backlog with the internal track ID “SJS-24759”. I will update you as soon as there is any information.

    Regarding “Do I still need to call sheet.setDataView(view) to reset the filter?” – Yes, you may need to use this as a workaround to reset the filter.

    Regarding “Is there a way to check if TableSheet is being filtered?” – You can track filtering actions in TableSheet using the filterTextSelectAction and filterByCondition commands via the CommandManager. These commands are triggered internally whenever a filtering operation is performed on the TableSheet.

    To detect when a filter is applied, you can add a listener to the CommandManager as shown below:

    spread.commandManager().addListener('appListener', (args) => {
        if (args.command.cmd === "filterTextSelectAction" || args.command.cmd === "filterByCondition") {
            console.log("TableSheet filtered!");
        }
    });

    How It Works:

    • The CommandManager listens for filter-related actions.
    • If the command matches “filterTextSelectAction” or “filterByCondition”, it logs a message indicating that filtering has been applied.

    Please refer to the attached GIF and sample for further reference.

    Gif:

    Sample: clear_table_sheet_filter.zip

    Best regards,

    Priyam

Need extra support?

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

Learn More

Forum Channels