1. Datagrid displays fine
2. Datagrid dataprovider = lstRepRankDrill[0].record which is _inside_ the
lstRepRankDrill XMLListCollection. This XML hierarchy format is returned by
myFlexSQL web service against SQLServer2005.
3. trace(lstRepRankDrill[0].record.toXMLString()) gives the 60 "rows" of data
that appear in the datagrid.
4. The XMLListCollection format:
lstRepRankDrill (mx.collections.XMLListCollection)
...[0] (XML)
......<results>
.........<record>
............<chnl_cd>
............<rep_nm>
.........<record>
.........<record> etc
Code:
- Datagrid declaration
<mx:DataGrid dataProvider="{lstRepRank[0].record}" </mx:DataGrid>
- load XMLListCollection with back end result set
lstRepRankDrill = new XMLListCollection(myFlexsql.xmlData.results);
- add filter
lstRepRankDrill.filterFunction = filterRepRankDtlChnl;
- filter code
private function filterRepRankDtlChnl(item:XML):Boolean{
...trace(item.toXMLString());
...if(item.results.record.chnl_cd == "PREM") return true;
......else return false;
}
NOTE: trace(item.toXMLString()); in filter code prints all the data, not just
one "row". Trace=
item (XML)
...<results>
......<record>
......<record> etc all 60 of them.
So even though the grid data is fine, the filter is getting passed all the
data, and the filter gets called once. I wonder if it is because the data is
hierarchical and there is a discrepancy between the dataprovider and the filter
owner. The dataprovider is _inside_ the lstRepRankDrill XMLListCollection as
lstRepRankDrill[0].record. The filter is placed on the outside
XMLListCollection :
lstRepRankDrill.filterFunction = filterRepRankDtlChnl;
Its almost like where the filter is placed (XMLListCollection rather than
dataprovider subnode lstRepRankDrill[0].record) is causing all the data to be
forwarded into filter param item, and passed only once.
--- In [email protected], "Tracy Spratt" <tr...@...> wrote:
>
> Lets clarify terminology. "dataProvider" must always be a list of some
> kind, like an array, and XMLList an ArrayCollection or an XMLListCollection.
> It can not be a single XML node.
>
>
>
> This expression should return an XMLList: lstRepRankDrill[0].record
>
>
>
> If you trace(lstRepRankDrill[0].record.toXMLString()); //what do you see?
>
>
>
> Does your DG display correctly without the filter?
>
>
>
> Post the declaration for the dataGrid.
>
>
>
> Tracy Spratt,
>
> Lariat Services, development services available
>
> _____
>
> From: [email protected] [mailto:[email protected]] On
> Behalf Of chigwell23
> Sent: Thursday, August 27, 2009 2:09 PM
> To: [email protected]
> Subject: [flexcoders] Re: Apply filterFunction to datagrid XMLListCollection
> dataprovider question
>
>
>
>
>
> thanks for your time Tracy, yes absolutely the whole shooting match is sent
> to the _one_ call to the function i.e. lstRepRankDrill, which is actually
> more than the dataprovider which is {lstRepRankDrill[0].record}. I know that
> the fact there is only one call to the filter is significant, but do not
> know why, unless it is because I have to put the filter on
> lstRepRankDrill.filterFunction = filterRepRankDtlChnl; and it is
> hierarchical. Obviously I cannot put the filter on lstRepRankDrill[0].record
> as it is XML and not an XMLListCollection. Am using DG not ADG if that makes
> any difference. Eventually found 2 other Google questions out there with the
> same scenario - one call to the filter with the whole XMLListCollection
> being passed. No answers to them :-(
>
> --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
> "Tracy Spratt" <tracy@> wrote:
> >
> > I don't use ADG all that much, but the filter functions should get a
> > "record" node for each call of the filter function. Have you used
> > toXMLString() to trace out the item? Inside the filter function you can
> use
> > any e4x expressions to traverse the xml, down into the child nodes or even
> > up to parent nodes.
> >
> >
> >
> > I am pretty sure you are not getting the entire dataProvider in the
> > function. Do the trace.
> >
> >
> >
> > Tracy Spratt,
> >
> > Lariat Services, development services available
> >
> > _____
> >
> > From: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> [mailto:flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com]
> On
> > Behalf Of chigwell23
> > Sent: Thursday, August 27, 2009 4:25 AM
> > To: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> > Subject: [flexcoders] Re: Apply filterFunction to datagrid
> XMLListCollection
> > dataprovider question
> >
> >
> >
> >
> >
> > I wonder if is even possible to use the filter function with hierarchical
> > XML, as all of the examples I have seen are of array collections or flat
> > XML?
> >
> > This I think is the problem - the complete data provider is being passed
> > into the item parameter of the filter i.e. the xml hierarchy in its
> > entirety. I am presuming that the filter wants one "row" at a time so it
> can
> > do its compare. Where do I have control of this? I am not sure I do since
> > the only code is
> >
> > lstRepRankDrill.filterFunction = filterRepRankDtlChnl;
> >
> > The data provider is
> >
> > dataProvider="{lstRepRankDrill[0].record}" in order to dig into the XML
> > hierarchy to get to the data. (Wrapper nodes are returned by SQL back end.
>
> >
> > --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
> > "Tracy Spratt" <tracy@> wrote:
> > >
> > > Break the code into smaller pieces and debug to see what is wrong.
> > >
> > >
> > >
> > > Tracy Spratt,
> > >
> > > Lariat Services, development services available
> > >
> > > _____
> > >
> > > From: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> > [mailto:flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com]
> > On
> > > Behalf Of chigwell23
> > > Sent: Thursday, August 27, 2009 2:40 AM
> > > To: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> > > Subject: [flexcoders] Apply filterFunction to datagrid XMLListCollection
> > > dataprovider question
> > >
> > >
> > >
> > >
> > >
> > > private function filterRepRankDtlChnl(item:Object):Boolean{
> > > if(item.results.record.chnl_cd == "PREM") return true;
> > > else return false;
> > > }
> > >
> > > Filter is not filtering and I think it maybe item.results.record.chnl_cd
> -
> > > the item:Object is in this format:
> > >
> > > item
> > > ...<results>
> > > ......<record>
> > > .........<chnl_cd>
> > > .........<rep_nm> etc
> > >
> > > What is the correct "path" for chnl_cd and might this be the problem?
> TIA,
> > >
> > > Mic.
> > >
> >
>