web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

to filter the grid using click button on form

(1) ShareShare
ReportReport
Posted on by 1,836
i have made the form simple list form having only one datasource , i need to filter the grid on form when i click on the button on form and i am going to pass how can i get this done can any one guide me on this .
 
 
 
thanks ,
Regards,
Dinesh
I have the same question (0)
  • Waed Ayyad Profile Picture
    8,961 Super User 2025 Season 2 on at
    to filter the grid using click button on form
    Hi Dinesh,
     
    Do you want to filter the grid based on specific field values? Can you tell me what is the filter that you want to add?
     
     
    Thanks,
    Waed Ayyad
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the grid using click button on form
    hi ,
    thanks for reply ,
     i need to filter the form based on warehouse and from date and to date when i click filter button on from, can you guide me on this or share any link here is my form design ,
  • Suggested answer
    Waed Ayyad Profile Picture
    8,961 Super User 2025 Season 2 on at
    to filter the grid using click button on form
    Hi,
     
    The Filters that came with Simple List Pattern, doesn't fit your requirement.
     
     
     
    If you should add custom button, then you should add your range by code and call the execute Query method. Check the below blog 
     
     
    Thanks,
    Waed Ayyad
     
    If this helped, please mark it as "Verified" for others facing the same issue
  • Suggested answer
    Layan Jwei Profile Picture
    8,049 Super User 2025 Season 2 on at
    to filter the grid using click button on form
    Hi Dinesh,
     
    It seems it's the same question as ur old thread but this time you want to do it via button.
     
    Can you please verify the answers that helped
     
    Did u try my suggestion there? Because you still need it. You need to update us with what you tried so that we can help you and think of sth else if needed.
     
    If it worked with you in the other question (the code inside the execute query of the line datasource). Then please go back to the blog i sent you in the other thread (https://daxingwitheshant.blogspot.com/2019/04/how-to-filter-grid-based-on-control.html) and maybe put the code that was in the modified method in the clicked method instead ( i mean call execute query method inside the clicked method)
     
    You can add more ranges if you don't want LocationId alone.
     
    Thanks,
    Layan Jweihan 
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the grid using click button on form
    hi , thanks for reply ,
    i have done below code on form , i need to refresh the from and clear the filter when i click on refresh , but that is not happening , code is working as required , can you please guid me on this . i am still facing the varfying issue but i will all your answers ,
      [DataSource]
        class DTDMCHeaderLines
        {
            /// <summary>
            ///
            /// </summary>
            public void executeQuery()
            {
                QueryBuildRange QcustomerFilter,invoiceDate;
    
                QcustomerFilter =
                SysQuery::findOrCreateRange(DTDMCHeaderLines_ds.query().datasourceTable(tableNum(DTDMCHeaderLines)),fieldNum(DTDMCHeaderLines, InventLocationId));
    
                invoiceDate  =
                SysQuery::findOrCreateRange(DTDMCHeaderLines_ds.query().datasourceTable(tableNum(DTDMCHeaderLines)),fieldNum(DTDMCHeaderLines,InvoiceDate ));
    
                if (DTWarehouse.text()!= "")
                {
                    QcustomerFilter.value(queryValue(DTWarehouse.text()));
                }
                else
                {
                    QcustomerFilter.value(SysQuery::valueUnlimited());
                }
    
                if (DTFormDate.dateValue() != dateNull() && DTToDate.dateValue() != dateNull())
                {
                    invoiceDate.value(SysQuery::range(DTFormDate.dateValue(),DTToDate.dateValue()));
                }
                else
                {
                    invoiceDate.value(SysQuery::valueUnlimited());
                }
                super();
            }
        }
    
      [Control("Button")]
        class FilterButton
        {
            /// <summary>
            ///
            /// </summary>
            public void clicked()
            {
                super();
                DTDMCHeaderLines_ds.executeQuery();
            }
        }
    thanks,
    Regards,
    Dinesh
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    to filter the grid using click button on form
    You just need to call clearranges() method when click on refresh button.
  • Layan Jwei Profile Picture
    8,049 Super User 2025 Season 2 on at
    to filter the grid using click button on form
    Hi Dinesh,
     
    In the blog i sent you, if you noticed they called "clear ranges" in the modified method so you can utilize that code and put it in the required place.
     
     Please don't forget to verify the answers that helped.

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the grid using click button on form
    I am not getting where should i write the clerarRanges can you please guide me ,
     
    thanks,
    Regards,
    Dinesh
     
     
  • Dineshkarlekar Profile Picture
    1,836 on at
    to filter the grid using click button on form
    i have done below code but form is not opening , still issue with clear ranges.
     public void executeQuery()
            {    
                //QueryBuildDataSource      DTDMCHeaderLines_ds;
                QueryBuildRange QcustomerFilter,invoiceDate;
                date      fromdate , todate;
    
                QcustomerFilter =
                SysQuery::findOrCreateRange(DTDMCHeaderLines_ds.query().datasourceTable(tableNum(DTDMCHeaderLines)),fieldNum(DTDMCHeaderLines, InventLocationId));
                invoiceDate  =
                SysQuery::findOrCreateRange(DTDMCHeaderLines_ds.query().datasourceTable(tableNum(DTDMCHeaderLines)),fieldNum(DTDMCHeaderLines,InvoiceDate ));
    
                this.query().datasourceTable(tableNum(DTDMCHeaderLines)).clearRanges();
     
  • Suggested answer
    Waed Ayyad Profile Picture
    8,961 Super User 2025 Season 2 on at
    to filter the grid using click button on form
    Hi,
     
    Try to add your clear statement on the Init of your form /Form Datasource, also on the click of your button before calling the Filter code.
     
    I have one note you want to add the ranges when you click the button, so I think if you create a new method to do the Filters that would be better, as you don't want every time the execute query is called to add range again.
     
     
     [Control("Button")]
        class FilterButton
        {
            /// <summary>
            ///
            /// </summary>
            public void clicked()
            {
                super();
                // Clear Ranges statement.
                // New method that add range
                DTDMCHeaderLines_ds.executeQuery();
            }
        }
    Thanks,
    Waed Ayyad
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,882

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 794 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 525 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans