How to add features to a feature Layer

Discussion created by LanceWeaver on Apr 13, 2012
Latest reply on May 23, 2012 by LanceWeaver
You would think this would be easy.     I want to manually add features  (from results of a FindTask) to my feature layer.

All examples in the help add such results as graphics directly to the Map [with ].  But I would like to add them to one of my FeatureLayers.  [esri.layers.FeatureLayer[myFeatureLayer].graphics]

This is what the help does (which I dont want to do)

                var items = dojo.forEach(results,function(rslt){
                    var desc = "<p>Name :"+rslt.attributes.TITLE+"<br>State:</p>";
                    var graphic = rslt;
                    return rslt.attributes;

This is what I want to do.  The features are added, but they do not display on the map even if I call .refresh() or readd the featureLayer.

                var items =,function(rslt){
                    return rslt.feature;

     = items;

Is this not possible?  It seems to me that adding features/graphics to a featureLayer is more flexible than just adding them roguely to the map.  Can they only be added with featureLayer.selectFeatures() or at creation of the new FeatureLayer?    I would like to add my featureLayer with MODE_SELECTION so nothing is fetched from the server, and then query the server with a FindTask and then add the results to my feature Layer.  I know how to do it with a .selectFeatues(query)  but I want to do it with a findTask not a query.