change renderer data to render different columns from same layer

381
1
11-07-2012 04:42 AM
JörgPossin
New Contributor III
I want to load a layer with a static layout which I created in ArcMap but I want to select the attribute column from a feature layer dynamically after loading the layer into the webclient. Every year has its own attribute column.

I tried this but it does not work:

dojo.connect(map, "onLayerAdd", function(layer) {
             if (layerKey == "zielabw11m2") {
              layer.renderer.Field = "M2_11_PZ";
             }
             else if (layerKey == "zielabw10m2") {
              layer.renderer.Field = "M2_10_PZ";
             }
             else if (layerKey == "zielabw07m2") {
              layer.renderer.Field = "M2_07_PZ";
             }
            }
        });  

I debugged it and Firebug throws no error. The layer appears but always with the same attribute column which I selected in ArcMap. Must I reload the layer? But how?
0 Kudos
1 Reply
JörgPossin
New Contributor III
I solved the problem and choose the attribute field before loading the layer in a hard coded renderer.
0 Kudos