So surprisingly, just when I dedice to post a long help request after spending SO much hours on this problem, suddently I find the solution by myself
I hope it will help others, I think this ability is extremely important and helpful when creating a real-time application in any kind of organization!
So here is my final result:
- One full layer of all incidents
- A filter widget with 5 pre-made filters: Incidents of Today, All open Incidents, Incidents between dates, incidents by keywords*2
- Filter widget shows-up on startup of the application
- In the PostCreate function of the Filter Widget I apply the first filter (all of today's incidents)
- The user can choose to turn that filter off and/or use other filters, such as dates and keyword search.
With no previous knowledge or basic understanding of how the code works this might get a bit messy and confusing.. I hope it will make sense to whoever finds it relevant.
How to implement:
* Create a date filter with the WAB that just simply filters the layer by a specific date (any date).
* To be able to run the filter on startup on the widget, the filter SHOULD NOT have an interactive parameters option.
* To enable the filter when the widget is opened, insert the following code inside the PostCreate function of the Widget.js file in the Filter widget's folder-
if (filterObj.name === 'NAME OF THE FILTER AS DEFINED IN THE WIDGET SETTINGS'){
query('.header',node)[0].click();
}
* Open the Filter configuration file (usually located in the following path - C:\Program Files\ArcGIS\WebAppBuilderForArcGIS\server\apps\*APPID*\configs\Filter\ ) and find the targeted filter you created on the first step. If you followed the steps correctly, you should find a field named "expr" TWICE for this filter. Just replace the existing value with the following syntax - "your_datetime_field >= CURRENT_DATE()-0.5".
* I've tried using SQL functions such as GETDATE and DATEADD and such which are not supported... apparentaly CURRENT_DATE works perfectly and -0.5 is a must for today's records. When using -1 I get records for 2 days.
Overall it's a bit hard to explain but hopefully it was clear enough.
Regards,
Shay.