change renderer data to render different columns from same layer

Discussion created by jpossin on Nov 7, 2012
Latest reply on Nov 19, 2012 by jpossin
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?