D365 Finance & Operations and Dynamics AX Forum

Expand all | Collapse all

Clearing grid filters

  • 1.  Clearing grid filters

    TOP CONTRIBUTOR
    Posted Jul 11, 2019 11:42 AM
    ​Our users have asked for a "Clear filter" button on a custom form that clears the entries in the top part of the form and also clears the filters in the grid.  I'm able to clear the filters in the dropdown boxes at the top of the form, but how do I clear the column filters in the grid?

    Clear filters


    ------------------------------
    Rudy Salcedo
    Senior Programmer/Analyst
    LaForce, Inc
    Green Bay WI
    ------------------------------
    Conference-AXUG_200x200


  • 2.  RE: Clearing grid filters

    GOLD CONTRIBUTOR
    Posted Jul 12, 2019 07:16 AM
    Have you tried calling the mycontrol.filter("") method on each control of you grid?  You might also need to call yourDataSource.research() to refresh the grid after.

    ------------------------------
    Steeve Gilbert
    Software Development Supervisor
    Boa-Franc S.E.N.C.
    QC, Canada
    ------------------------------

    Conference-AXUG_200x200


  • 3.  RE: Clearing grid filters

    TOP CONTRIBUTOR
    Posted Jul 23, 2019 04:12 PM
    ​Thanks for the suggestion @Steeve Gilbert.  I tried it on one of the fields and oddly instead of blanking out the filter, it was given the value of the first record​ in the grid.  I did manage to figure out something that worked though.

    ------------------------------
    Rudy Salcedo
    Senior Programmer/Analyst
    LaForce, Inc
    Green Bay WI
    ------------------------------

    Conference-AXUG_200x200


  • 4.  RE: Clearing grid filters

    TOP CONTRIBUTOR
    Posted Jul 12, 2019 09:47 AM
    Could you do something like this?

    [Control("Button")]
    class ClearFiltersButton
    {
        public void clicked()
        {
        FormDataSource ds = this.formRun().dataSource("DataSourceName") as FormDataSource;
        ds.sortClear();
        ds.clearRanges();
        }
    }

    ------------------------------
    Alex Meyer
    Director of Dynamics AX/365 for Finance & Operations Development
    Fastpath
    Des Moines, IA
    ------------------------------

    Conference-AXUG_200x200


  • 5.  RE: Clearing grid filters

    TOP CONTRIBUTOR
    Posted Jul 23, 2019 04:18 PM
    Thanks @Alex Meyer, I tried your suggestion but kept getting an error during compilation that I couldn't resolve.  I ended up adding code in the clicked method of the button to clear the dropdown filter textboxes, and then added datasource.executeQuery() and a form.clear()  statements.  Might not be the best way to do it, but it works.

    ------------------------------
    Rudy Salcedo
    Senior Programmer/Analyst
    LaForce, Inc
    Green Bay WI
    ------------------------------

    Conference-AXUG_200x200


If you've found this thread useful, dive deeper into User Group community content by role