Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

to filter the grid using click button on form

(1) ShareShare
ReportReport
Posted on by 1,457
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
  • Waed Ayyad Profile Picture
    Waed Ayyad 6,556 Super User 2024 Season 2 on at
    to filter the grid using click button on form
    Hi,
     
    Did you try my comment? Is it helpful for you? If yes, please verify the answer if not tell me where you reach on your code to help you.
     
     
    Thanks,
    Waed Ayyad
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    to filter the grid using click button on form
    I don't think you still need to write some code like I said before to clear ranges. You just need to remove those filled values and do soft refresh.
     
    And regarding your code, it doesn't work because you added ranges and removed ranges which eventually doesn't keep any ranges.
  • Layan Jwei Profile Picture
    Layan Jwei 7,266 Super User 2024 Season 2 on at
    to filter the grid using click button on form
    Hi Dinesh,

    What do you mean form is not opening? didn't you say the everything is working fine except for clearing the range when refreshing?

    Also Why are u calling "clear ranges" now after putting the ranges, this means your range will disappear directly after you filter, you need to put the line of code before filtering

    Please give us exact requirement

    1. When u open the form for the very first time, do you want anything to be filtered? or show everything?
    2. Now when you click filter, i think u want to apply the filter right?
    3. Now when you click refresh you want to reset the filter and show everything?
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,556 Super User 2024 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
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 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();
     
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 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
     
     
  • Layan Jwei Profile Picture
    Layan Jwei 7,266 Super User 2024 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
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    to filter the grid using click button on form
    You just need to call clearranges() method when click on refresh button.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 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
    Layan Jwei Profile Picture
    Layan Jwei 7,266 Super User 2024 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
     

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,735 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,466 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans