esearch default filter

5218
35
03-22-2016 09:59 AM
RudoDuncan
New Contributor II


Is it possible to display the first couple of days of calls for service so that my users can see the last 48hrs by default? Then if they wanted to see something prior to that they can search for it using the filter. Currently, my users have to put in a date filter every time they open the application.

0 Kudos
35 Replies
RobertScheitlin__GISP
MVP Emeritus

Rudo,

  I am thinking that may work or the other option as I mentioned earlier is to add a new search expression to the search layer.

0 Kudos
RudoDuncan
New Contributor II

Hey Robert does your update make it easier to fix my small issue?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rudo,

  No the last update did not doing anything to help your issue. But I think I have a resolution now.

in the Widget.js make this change to the _queryFromUrl function (line 4 and 5):

_queryFromURL: function (value, slayerId, exprNum, close) {
        slayerId = typeof slayerId !== 'undefined' ? slayerId : 0;
        exprNum = typeof exprNum !== 'undefined' ? exprNum : 0;
        this.AttributeLayerIndex = slayerId;
        this.expressIndex = exprNum;

And then add lines 4 thru 9 to the Widget.js code block that started with line 1

//now check if there is a url search to do
            var myObject = this.getUrlParams();
            if (myObject.esearch) {
              if(myObject.esearch === "last48"){
                var today = new Date();
                var priorDate = new Date(today.getTime() - (((24 * 60 * 60 * 1000) - 1000) * 2));
                var priorDateStr = this._formatDate(priorDate.getTime(), 'yyyy/MM/dd');
                myObject.esearch = "|||||||||||" + priorDateStr + "~" + this._formatDate(new Date().getTime(), 'yyyy/MM/dd');
              }

The use this url string as an example:

esearch=last48&slayer=0&exprnum=0

0 Kudos
RudoDuncan
New Contributor II

Actually I think you did fix it in your update. Only thing is, I'm not using the new version of esearch.

In your new version it displays the box that I am looking for.

Is there a way to add that option or upgrade my application?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rudo,

  This is going to be an issue you will have to continually face now that you made a copy of the widget with a new name and modified to suit your needs. Yes you can add this new functionality if you spend the time going through the code to find the changes I have made. I will not be able to help you in this endeavor though as this I need to spend my time supporting my widgets, not custom one off versions ( I have to draw the support line somewhere ).

0 Kudos
RudoDuncan
New Contributor II

Completely understand, I will probably build a new application and keep the esearch name, this way there won't be too much to code when I upgrade. Thank You

0 Kudos