I have a map with several layers and I want to have each layer in separate folder below the root. Can anyone help me with js source code to do that? (geoext2 documentation only separate layers between base layers and overlay layers).
I think what you need is the general
gx_layercontainer, this one does not distinguish between baselayers or overlays. You can see it in action in the official example http://geoext.github.io/geoext2/examples/tree/tree-legend.html