View Full Version : set a datapointer from addNode(...)?
tspratt
12-17-2003, 12:17 PM
If I have created a new node using addNode(), how can I set a datapointer to it?
for example:
var nodeNew = myDatapointer.addNode(sNodeName);
var datapointerNew = ????;
There may be other nodes under myDatapointer with the same node name, so I can't just set the new datapointer to the sNodeName.
This does not seem to work:
sXpath = nodeNew.getNodeAttribute("xpath");
Any suggestions?
Thanks in advance!
Tracy
antun
12-17-2003, 01:03 PM
You can use the setXPath() of datapointer:
<canvas debug="true">
<debug x="150" height="300" />
<dataset name="myds">
<myrootnode>
<foo bar="1">One</foo>
</myrootnode>
</dataset>
<datapointer name="mydp" xpath="myds:/myrootnode/foo" />
<button>Make XML
<method event="onclick">
mydp.addNode( "myaddednode", "hello", { foo: "bar" } );
mydp.setXPath( "myaddednode" );
Debug.write( mydp.serialize() );
// Write out the contents of the dataset for debugging
var dspointer = canvas.datasets.myds.getPointer();
// debug.write( dspointer.serialize() );
</method>
</button>
</canvas>
Hope this helps!
-Antun
http://www.laszlosystems.com/developers/learn/documentation/lzxref/datapointer.php
tspratt
12-17-2003, 02:17 PM
I can use an index counter and then selectChild and selectNext(index-1) to get my datapointer.
I would still like to know if there is a more "elegant" solution.
Thanks!
Tracy
tspratt
12-17-2003, 02:21 PM
because I may have more than one node under mydp with the name 'myaddednode'.
I did find a solution though, see my earlier post.
thanks, Antun.
antun
12-17-2003, 03:27 PM
There isn't a more elegant solution in 1.0.x, however with the Krank release, there will be a far more fluid way of adding nodes.
-Antun
Originally posted by tspratt
I would still like to know if there is a more "elegant" solution..
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.