Yes it would be but, I was'nt sure how to do it but, your message got me thinking that I was rendering the parent node when I should be rendering the Child so...this it was I came up with and it works.
So the user adds a new value to the database. This will properly add a new child to a parent that is expanded or it will force an unexpanded parent to expand and get its children via callback (Which will also include the new value the user added). The only thing I have to figure out is how to select the new child after a callback.
I have also included a routine I came up with that changes a nodes text. If you have any feedback on how to make these better I would appreciate it.
function CHAS_AddTrvNode(strTrvClientID, strParentID, strNewNodeID, nXml)
{
//alert(strTrvClientID + ' , ' + strParentID + ' , ' + strNewNodeID + ' , ' + nXml);
var oTree = dnn.controls.controls[strTrvClientID]; //obtain ref to dnntree
var oPNode = oTree.DOM.findNode('n', 'id', strParentID); //find the parent DNNNode
if (oPNode != null)
{
var oTPNode = new dnn.controls.DNNTreeNode(oPNode); //cast it to DNNTreeNode
if (!oTPNode.expanded)
{
oTree.expandNode(oTPNode);
} else {
oTree.selTreeNode.selected = null; //Clear the selected node
oTree.assignCss(oTree.selTreeNode);
oTPNode.node.appendXml(nXml);
var oCNode = oTree.DOM.findNode('n', 'id', strNewNodeID); //find Child DNNNode
var oCTNode = new dnn.controls.DNNTreeNode(oCNode);
var oCtr = oTree.getChildControl(oTPNode.id, 'pctr'); //obtain ref to parent
oTree.renderNode(oCTNode.node, oCtr, false); //render new Child Node xml
oTree.update(); //update tree's xml so postback will persist
}
} else {
alert('Parent node not found: ' + strParentID);
}
}
function CHAS_UpTNodeDesc(strTrvClientID, strNodeID, strNodeDesc)
{
var oTree = dnn.controls.controls[strTrvClientID]; //obtain ref to dnntree
var oNode = oTree.DOM.findNode('n', 'id', strNodeID); //find DNNNode
var oTNode = new dnn.controls.DNNTreeNode(oNode); //cast it to DNNTreeNode
var oCtr = oTree.getChildControl(oTNode.id, 't'); //obtain ref the span with the text
oCtr.innerHTML = strNodeDesc;
oTNode.text = strNodeDesc;
oTree.update(); //update tree's xml so postback will persist
}