set date range programmatically

Answered
Michael T asked on June 4, 2021

how can we do the equivalent of setting the filter dialog date picker programmatically?
e.g. setting dates to be filtered after X date and before Y date
thank you,
Mike
 
 

1 answer

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster June 7, 2021

Hello, Mike,
 
Thank you for posting on our forum.
 
You can apply the desired filtering by defining the Filter Object associated with a chosen field. Use the Date Query Object to specify filtering for date fields.
 
Please note that you can always configure the desired aspects using UI (e.g., the mentioned filter pop-up) and save the configuration using the "Save" tab of the Toolbar. The saved JSON file can serve as a reference.
 
If you want to filter dynamically (after the initial report is opened), use the setFilter API call. This method accepts the hierarchy name and the mentioned `filter` object as arguments.
Here is a JSFiddle demonstrating usage of the `setFilter` method: API calls setFilter, getFilter, clearFilter - JSFiddle.
 
Please let us know if it works.
Feel free to contact us if other questions arise.
 
Best regards,
Illia

Please login or Register to Submit Answer