[Project_owners] Deleting a tree row

Neil Deakin enndeakin at sympatico.ca
Thu Mar 24 16:23:13 EST 2005


maple guy wrote:

>Hi
>
>What is the right way of deleting a row in a XUL tree? The code I'm
>using just deletes the text in the columns. And an empty row is still
>visible in the tree. I'm using a tree with the following set:
>
>flags="dont-build-content"  
>datasources="rdf:null"
>
>The way I delete the rows is:
>function deleteRow(datasource, tree, node)
>{
>    var props = datasource.ArcLabelsOut(node);
>    var prop;
>    
>    while(props.hasMoreElements())
>    {
>        prop = props.getNext();
>        var target = datasource.GetTarget(node, prop, true);
>        datasource.Unassert(node, prop, target);
>    }
>    props = datasource.ArcLabelsIn(node);
>    
>    while(props.hasMoreElements())
>    {
>        prop = props.getNext();
>    }
>}
>
>BR
>  
>

You also need to remove the resource from its container.

var rdfcutils = Components.classes["@mozilla.org/rdf/container-utils;1"].
                          
getService(Components.interfaces.nsIRDFContainerUtils);
var container = rdfcutils.MakeSeq(datasource, containerResource);

...

container.RemoveElement(target, true);

/ Neil



More information about the Project_owners mailing list