schlot

featurelayer - how to remove filterexpression

Discussion created by schlot on Sep 9, 2013
Latest reply on Sep 11, 2013 by schlot
I have a dropdown list of choices that I'm using as a parameter for a filterExpression on a featureLayer.  This works just fine, until I tried to remove the filter.  Looking through the API,  I'm not seeing anything that seems suitable to get rid of this.  I thought I could just set it back to the original default filterExpression (which returns as  "" if I look at the layer before I set the filter).  I've also tried using clearSelection, which doesn't seem like what I want, since I didn't do a selection of features, I set a filter.

function filterFacilityByAgency() {
    var e = dijit.byId("facilitySelect");
    var code = e.value;
    map.graphics.clear();
    map.infoWindow.hide(); 
    var filterExpression = "Agency = '" + code + "'";
    buildingLayer.setDefinitionExpression(filterExpression);
    buildingLayer.setVisibility(true);
}
function clearBuildingLayer () {
  var orgExp = map.getLayer('buildingLayer').defaultDefinitionExpression;  //NOTE:  returns ""
buildingLayer.setDefinitionExpression(orgExp);
map.getLayer('buildingLayer').clearSelection;
    var select = dijit.byId("facilitySelect");
    select.reset();
}

Outcomes