I have three sublayers and I just want to exclude one of the sublayer..so this is not going to help me as I do want those other two layers in the legend
How about in Viewer 3.2? Something like this in config.xml: <layer label="Map" type="dynamic" visible="true" alpha="1" url="http://.../arcgis/rest/services/my_vector/MapServer" > <sublayer id="1" label="Asemat"/> </layer> And in LegendWidget.xml: <excludelayer>Asemat</excludelayer> Does not seem to work...
I did this by adding and if statement to the CreateChildren function in TOCMapLayerItem.as.
I kept a global var of layers and sublayers I wanted and checked against that in the if statement. I did this because my TOC was dynamic. For your case you could just read from a xml and check against it.
Put the if statement around layerInfos.push(layerInfo);