esearch default filter

5187
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,

   You have two choices:

  1. You use the url search Web AppBuilder for ArcGIS | Help - Enhanced Search widget | URL Search
  2. Or you edit the widget.js to do the search for your once the widget opens.
RudoDuncan
New Contributor II

When the user clicks on the widget I want the last 48hrs to display by default. From there give my users the power to filter whatever they need after that. Where in the widget.js can I put that parameter in?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rudo,

I can keep on being your personal programmer . You are going to have to try to do stuff yourself or hire a programmer.

In the Widget.js after line 910 insert this code, where line 14: 5, 0, equals the search layer number (so 5 is the sixth configured search layer) and 0 is the first expression for that layer.

//Now execute your default search get the last 48 hours
var d = new Date();
var endTime = locale.format(d, {
  selector: "date",
  datePattern: "yyyy-MM-dd h:mm:ss a"
});
d.setDate(d.getDate() - 2);
var startTime = locale.format(d, {
  selector: "date",
  datePattern: "yyyy-MM-dd h:mm:ss a"
});

this._queryFromURL(startTime + '~' + endTime, 5, 0, false);
RudoDuncan
New Contributor II

I'm sorry, I am learning the developer side as I am going along, my apologies.

0 Kudos
RudoDuncan
New Contributor II

On line 13 you have 5,0. What do you mean by 6th configured search layer?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rudo,

  Each search layer that you have configured to be able to search is called a search layer (most being a different url then the others).

0 Kudos
RudoDuncan
New Contributor II

Yes, I realized that after I've sent the message sorry. I only have one.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rudo,

So it would be

this._queryFromURL(startTime + '~' + endTime, 0, 0, false);

You deleted a 0 for some reason and I made a change to the 4th parameter.

0 Kudos
RudoDuncan
New Contributor II

Is this what is should be?

Also is this how the url search parameters should look like?

devvm08:6024/ppdapp/?cfssearch=2014-11-10~2014-11-17

0 Kudos