Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
var dsPhotos = new <strong>Spry</strong>.Data.XMLDataSet("/photos.php?galleryid=2000",<br />
"/gallery/photos/photo");<br />
...<br />
dsPhotos.distinct(); // Remove all duplicate rows.<br />
In this context, the term duplicate row appliestoasituationinwhicheverycolumninthedatasetcontainsidentical<br />
information in 2 or more rows.<br />
To run the distinct() method automatically whenever data is loaded into a data set, use the "distinctOnLoad"<br />
option to the constructor.<br />
var dsPhotos = new <strong>Spry</strong>.Data.XMLDataSet("/photos.php?galleryid=2000",<br />
"/gallery/photos/photo", { distinctOnLoad: true });<br />
The distinct() method is destructive, so it discards any nondistinct rows. The only way to get the data back is to<br />
reload the XML data.<br />
Filter data<br />
Data sets support both destructive and non-destructive filtering.<br />
Beforeusingeithermethodoffiltering,supplyafilterfunctionthattakesadataset,rowobjectandrowNumber.This<br />
function is invoked by the data sets filtering methods for each row in the data set. The function must return either<br />
the row object passed to the function, or a new row object, meant to replace the row passed into the function. For<br />
the function to filter out the row, it should return a null value.<br />
The data set's destructive filter method is filterData().Thismethodactuallyreplacesordiscardstherowsofthe<br />
data set. The only way to get the original data back is to reload the XML data of the data set.<br />
❖ Use the destructive filterData() method to permanently discard rows in a data set:<br />
...<br />
// Filter out all rows that don't have a path that begins<br />
// with the letter 's'.<br />
var myFilterFunc = function(dataSet, row, rowNumber)<br />
{<br />
if (row["@path"].search(/^s/) != -1)<br />
return row; // Return the row to keep it in the data set.<br />
return null; // Return null to remove the row from the data set.<br />
}dsPhotos.filterData(myFilterFunc); // Filter the rows in the data set.<br />
The filter function remains active, even when loading XML data from another URL, until you call filterData()<br />
with a null argument. Call filterData() with a null argument to uninstall your filter function.<br />
dsPhotos.filterData(null); // Turn off destructive filtering.<br />
The data set's nondestructive filter method is filter(). Unlike filterData(), filter() creates a new array of<br />
rows that reference the original data. As long as the filter function does not modify the row object passed into it, you<br />
can get the original data back by calling filter() and passing a null argument. Use the nondestructive filter()<br />
method to filter the rows in a data set.<br />
SPRY<br />
<strong>User</strong> <strong>Guide</strong><br />
125