// (Within the PostCreate function) var pMenu; pMenu = new Menu({}); pMenu.addChild(new MenuItem({ label: "Turn On", onClick: this._manualTurnOn })); pMenu.startup(); pMenu.bindDomNode(this.rowNode); // (Reference - Code above was added before this section shown below) if (this.containerNode) { domStyle.set(this.containerNode, 'display', showChildren ? 'block' : 'none'); }
Not sure if you were able to find a solution on your own, but I was able to modify nliu's TOC.JS (built on 2015-01-15 13:51:27.12) to create a context menu for each node and embed a parameter for each, that was passed to a function with onClick. In my case, I was using Feature Layers and using the context menu to open the corresponding FeatureTable by right-clicking the TOC node. The context menu was created for each TOC node and the Feature Layer url was added as a function parameter.
I couldn't find a way to create a single menu and bind it to each node, and still assign the appropriate url parameter, so I decided just to create a menu for each node. Not ideal, but it seems to work fine. No ill effects so far.
For Feature Layers, my context menu code was inserted after nliu's code - "this.rootLayer.on("load", j.hitch(this, this._createRootLayerTOC))"
My Code:
//console.debug(this.rootLayer);
//create variable to hold feature layer url
var layertopass = this.rootLayer.url;
//create context menu and child elements
var pMenu2 = new dijit.Menu({
targetNodeIds: [this.domNode]
});
pMenu2.addChild(new dijit.MenuItem({
label:"Attributes",
onClick: function(){
showFT(layertopass);
}
}));
pMenu2.startup();
The Feature Layer url string is passed to the showFT function, which uses it to create a new esri FeatureLayer, that is then used to create the corresponding new esri FeatureTable.
I'm not sure exactly how to handle dynamic layers for purposes of labeling, but I suspect you'll probably need to insert similar context menu in the "_createServiceLayerNode" section of nliu's code. Maybe try to grab the layer id and pass that to a labeling function. Just a guess, though.
Anyway... this worked for me. Hope it helps.