Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Get data<br />
After the XML data is loaded, it is flattened into a tabular format. Inside the data set, the data is actually stored as an<br />
array of objects (rows) with properties (columns) and values.<br />
The following example shows data selected with the /gallery/photos/photo XPath, in bold:<br />
<br />
John Doe<br />
john@doe.com<br />
<br />
<br />
<br />
<br />
<br />
<br />
The data set then flattens the set of nodes into a tabular format, that the following table represents.<br />
@path @width @height<br />
sun.jpg 16 16<br />
tree.jpg 16 16<br />
surf.jpg 16 16<br />
YoucangetalloftherowsinthedatasetbycallinggetData().Thedataisloadedasynchronously,soyoucanonly<br />
access the data after it is loaded. You might need to register an observer to be notified when the data is ready. For<br />
more information, see “Work with observer notifications” on page 126.<br />
❖ Use the getData() method to fetch all the rows in the data set. To get the value of a specific column, index into<br />
the row with the column name.<br />
var dsPhotos = new <strong>Spry</strong>.Data.XMLDataSet("/photos.php?galleryid=2000",<br />
"/gallery/photos/photo");<br />
...<br />
var rows = dsPhotos.getData(); // Get all rows.<br />
var path = rows[0]["@path"]; // Get the data in the "@path" column of the first row.<br />
Sort data<br />
❖ To sort the rows of a data set using the values in a given column, call the sort() method on the data set:<br />
var dsPhotos = new <strong>Spry</strong>.Data.XMLDataSet("/photos.php?galleryid=2000",<br />
"/gallery/photos/photo");<br />
...<br />
dsPhotos.sort("@path"); // Sort the rows of the data set using the "@path" column.<br />
Calling the sort() method of a data set sorts the rows in ascending order, using data in the specified column.<br />
SPRY<br />
<strong>User</strong> <strong>Guide</strong><br />
The sort() method takes two arguments. The first argument can be the name of the column, or an array of column<br />
names to use when sorting. If the first argument is an array, the first element of the array serves as the primary sort<br />
column; each column after that is used for secondary and tertiary sorting, and so on. The second argument is the<br />
sort order to use, and must be one of the following strings: "ascending", "descending", or "toggle". If the<br />
second argument is not specified, the sort order defaults to "ascending". Specifying "toggle" as the sort order causes<br />
the data sorted in "ascending" ordertobesortedin"descending" order, and the reverse. If the column was never<br />
sorted before, and the sort order used is "toggle", the data is initially sorted in "ascending" order.<br />
123