all groups > flash data integration > december 2004 >
You're in the

flash data integration

group:

Arggh! can someone please help me FilterFunc my Datagrid?



Arggh! can someone please help me FilterFunc my Datagrid? Ken Fine
12/28/2004 9:38:24 PM
flash data integration: I've been banging my head on this one for hours, and am about to go crazy
with it. Can someone point out what obvious thing I'm missing?
Scenario: I'm creating an XML object, and using that XML object to populate
a DataSet, which in turn populates a Datagrid. Datagrid sorts properly,
indicating it is hooked up OK. I'm trying to use the results of a combobox
to filter the dataset (and in turn, the grid). The datagrid won't filter,
either using the variable that's returned from the combobox, or a hardcoded
value. I'm on MX2004

My code is a little strange because I'm using the XFactor studio Xpath and
XmlDataSet classes available at http://www.xfactorstudio.com/Actionscript/,
but it's pretty straightforward. Mucho thanks to anyone who can help with
this. This is the only thing remaining to get my app into a usable state.

First, my combobox code, which is sorta irrelevant given that my datagrid
won't filter on a hardcoded value:

listenerObject = new Object();
listenerObject.change = function(eventObject){
trace ("listener detects change!")

//this grabs the value from the combobox
var myDropDownChoice
myDropDownChoice=(eventObject.target.getValue());
trace (myDropDownChoice);
setFilter(myDropDownChoice);
}
myDropDown.addEventListener("change", listenerObject)


// Then I declare my xpath stuff so I can return XML:

import com.xfactorstudio.xml.xpath.*;
import com.xfactorstudio.xml.XmlDataSet;
myXmlDataSet = new XmlDataSet();

myDataGrid.dataProvider = myXmlDataSet.dataProvider;
myXmlDataSet.URL = "images.xml";
myXmlDataSet.addQuery("Caption","/images/pic/caption");
myXmlDataSet.addQuery("Title","/images/pic/image");
myXmlDataSet.addQuery("PublicationDate","/images/pic/pubdate");
myXmlDataSet.addQuery("Category","/images/pic/category");

// I try and fail to filter my DataSet:

setFilter= new Object
setFilter= function (request) {
myXmlDataSet.filtered = false;
trace ("setting filter")
trace ("REQUEST" + (request));
myXmlDataSet.filtered = true;
myXmlDataSet.filterFunc = function(item:Object) {
return(item.Category == ("fun"));
trace ("filter is set");
}

// The machine returns a trace statement on all items except for the last:
trace ("filter is set");
// I haven't figured out what's the problem.

}

//Further down the page, I trigger the dataset:

myXmlDataSet.trigger();
stop();


If anyone has any bright ideas on what's wrong, I'd really appreciate the
help. Thanks.

-KF

answer Re: Arggh! can someone please help me FilterFunc my Datagrid? Ken Fine
12/29/2004 12:15:48 PM
Hopfully this will save someone some time: the xFactor studio XmlDataSet
object, which is totally great, does not support a filter method as the
Macromedia Datasets do. You'll either need to reload the data while feeding
a customized Xpath query, or use a different method.


[quoted text, click to view]

RE: Arggh! can someone please help me FilterFunc my Datagrid? neur
7/6/2006 12:34:29 PM
I've revised xfactor XPath4AS2 library

download from http://www.r-site.net/xpath4as2.asp

From http://www.developmentnow.com/g/70_2004_12_0_0_56394/Arggh-can-someone-please-help-me-FilterFunc-my-Datagrid.htm

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button