PDA

View Full Version : change order of xml elements in dataset


jocsch
10-17-2004, 12:45 PM
Imagine following situation:


<dataset name="items">
<item name="item1"/>
<item name="item3"/>
<item name="item2"/>
<item name="item4"/>
</dataset>


These are displayed in a list via data replication. The user should be able to reorder the items in the dataset, eg. move item2 one up.

Is it possible to do this in the dataset? I can't find a method to create a node in a specific position (so insert item2 after item1 && delete old item2 seems not to be possible).

Or is it awkward to depend on an order of the XML elements (and therefor neccessary to introduce an "order" attribute)?

Thanks,
Markus

bmadigan
10-17-2004, 06:08 PM
Markus

Not sure if this will help or not, but I believe you can use Xpath with Laszlo.

http://www.developer.com/xml/article.php/1560361

But I'm not sure this is right, I just wanted to bring it up for future reference, as well as a possible solution for your problem.

jocsch
10-17-2004, 11:52 PM
yes it's possible to use xpath. But that implies the need of an additional "order" attribute which can be queried with xpath.
If possible I want to avoid this additional attribute.

jocsch
10-18-2004, 05:38 AM
OK. I found it. If someone is interested:


this.datapath.p.parentNode.insertBefore(this.datap ath.p,
this.datapath.p.getPreviousSibling());


This will insert the current node right above the previous sibling.

In the docs seems to be an error:

datapath.p returns a lzDataElement and not only a lzDataNode