Flex: Filter XMLListCollection even if test node doesn't exist
I want to show some data from an xml file inside a datagrid, so I do this:
<mx:AdvancedDataGrid id="dgDomains" dataProvider="{new XMLListCollection(xmlDomains..domain(deleted.toString() != '1'))}"
...
and the xml data looks like this:
<domains>
<domain>
<domainName>AGRICULTURE</domainName>
<deleted>1</deleted>
</domain>
<domain>
开发者_如何学编程 <domainName>IT</domainName>
<deleted/>
</domain>
</domains>
The filter fails if the "deleted" node isn't there. I get this error: Variable deleted is not defined.
Can someone help me improve the filter so that it will work in this case, too?
Thank you!
Its fails with error because filter can't apply's on null/undefined variables in your case delete, you may uses XML's elements function it will take care of null/undefined value
xmlDomain..domain.(elements('deleted') != '1')
above statement also return's all nodes in which delete is not defined
Hopes that helps
精彩评论