I am trying to use multiple filters on a nested data set using Spry but it does not work, no matter how many times I've re-read the code and verified that I'm using the code the right way. What is going on?
When I use a single non-destructive filter (ie... ds.filter()) on the nested data set, the filter works beautifully. However, when I want to use multiple filters (I use ds.addFilter()), it looks like my filter function (FilterByState) is not being kicked off.
I linked to the appropriate files, SpryData.js, xpath.js, SpryNestedXMLDataSet.js and SpryDataExtensions.js. These are the latest version, 1.6.1.
Why will ds.filter work and not ds.addFilter? I haven't written the second filter code yet because this is stopping me from moving forward. Even though, I haven't written that, shouldn't addFilter work too?
if (document.getElementById("dateSelect").selectedIndex != 0) {
document.getElementById("dateSelect").selectedIndex = 0;
}
});
var dsTopics = new Spry.Data.XMLDataSet("compliance.xml", "compliance/subject", {useCache: false });
var dsDocuments = new Spry.Data.NestedXMLDataSet(dsTopics, "doc");
var dsDates = new Spry.Data.XMLDataSet("compliance.xml", "compliance/subject/doc/date", {useCache: false, subPaths: "@num", distinctOnLoad: true, distinctFieldsOnLoad: ['date'], sortOnLoad: "@num", sortOrderOnLoad:"ascending"});
dsDates.setColumnType("@num", "number");
var currentSelection;
//var FilterByState;
function showDocuments(currentIndex) {
dsTopics.setCurrentRowNumber(currentIndex);
document.getElementById("stateSelect").selectedIndex = 0;
document.getElementById("dateSelect").selectedIndex = 0;
dsDocuments.removeAllFilters(true);
}
function ToggleFilter(selected, f) {
chosenState = selected;
if (selected != "") {
alert("something's selected");
dsDocuments.addFilter(f, true);
}
else {
alert("something is NOT selected");
dsDocuments.removeFilter(f, true);
}
//dsDocuments.applyFilters();
}
var chosenState;
var chosenDate;
function FilterByState(ds, row, rowNumber) {
alert("Filtering by state");
var currentSelection = document.getElementById("stateSelect").options[chosenState];
if (row["state"].search(currentSelection.value) != -1) {
return row;
}
else
return null;
}
function FilterByDate(ds, row, rowNumber) {
var currentSelectedDate = document.getElementById("dateSelect").options[chosenDate];
if (row["date"] == currentSelectedDate)
return row;
<subject>
<name>LTC Partnership</name>
<doc id="91000056">
<title>Alabama Long Term Care and Long Term Care Partnership Compliance</title>
<date num="200903">March 2009</date>
<state>AL</state>
</doc>
</subject>
</compliance>
Bookmarks