Run Filter in background executing programmatically an expession

1594
5
08-22-2016 03:59 PM
LefterisKoumis
Occasional Contributor III

As the tile says, I'd like to run the filter out of view in the background and perform a query on an expression without user's action. How can execute in the background the expression defined in the config_Filter.json?

Thanks.

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Sure just add the FilterManager require to what ever js code you want (like MapManager) and use a line like this:

FilterManager.getInstance().applyWidgetFilter(layerId, null, "your sql expression");

0 Kudos
LefterisKoumis
Occasional Contributor III

Thank you Robert. It works. However, since I am using tens of custom config.json files that are called in the url, ideally I would like to use something like the FilterManager.getInstance() (no sql statement) in AT (for example) and let the custom config.json call the custom config_Filter.json for the SQL expression (as it is already set up). Can it be done?

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   Sure you will need to use the appConfig var (this.appConfig) and loop through it to find the filter widget and then look at the config property and then the filters property to get the layerId and filter.expr

0 Kudos
LefterisKoumis
Occasional Contributor III

Thanks. 

So, if the widget is already openAtStart (true) and not visible, I can use this method to call an instance of the widget and execute the filter operation based on the custom_Filter? 

require(["jimu/WidgetManager"], function(WidgetManager) {
var wm = WidgetManager.openWidget("Filter");
});

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   No the widget does not have to be openAtStart or visible as the only thing you will be using from the widget itself is the widget config files.

0 Kudos