스파크 DataGrid에서 필터링하고 있습니다. 하지만 데이터를 필터링 할 수 없습니다. 그리고 dataprovider를 XML 파일로 사용하고 있습니다. 내 코드는 여기플렉스 4 - 필터가 작동하지 않습니다.
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
private function xmlListCollectionFilterFun(item : Object) : Boolean
{
var token : String = employeeName.text.toLowerCase();
var eName : String = employeeXMLList.child("Name");
var col : XMLList=tempXML.Employee.Name;
if(eName.toLowerCase().indexOf(token)!= -1)
{
return true;
}
return false;
}
protected function employeeName_changeHandler():void
{
if(employeeName.text.length == 0)
{
employeeXMLList.filterFunction = null;
}
else
{
employeeXMLList.filterFunction = xmlListCollectionFilterFun;
}
employeeXMLList.refresh();
}
]]>
</fx:Script>
<fx:Declarations>
<fx:XML id="tempXML"
source="skins/TextXmlFile.xml" />
<s:XMLListCollection id="employeeXMLList"
source="{tempXML.Employee}" filterFunction="xmlListCollectionFilterFun" />
</fx:Declarations>
<mx:VBox width="80%">
<s:TextInput id="employeeName" change="employeeName_changeHandler()"/>
<s:DataGrid id="dataGrid" dataProvider="{employeeXMLList}" width="100%" >
<s:columns>
<s:ArrayCollection>
<s:GridColumn id="nameCol" dataField="Name" headerText="Name:" />
<s:GridColumn id="idCol" dataField="Id" headerText="ID:"/>
<s:GridColumn id="mobileCol" dataField="Mobile" headerText="Mobile:"/>
<s:GridColumn id="alterCol" dataField="AlterMobile" headerText="Alternative Number"/>
</s:ArrayCollection>
</s:columns>
</s:DataGrid>
</mx:VBox>
</s:Application>
입니다 그리고 내 XML 파일은 다음과 같습니다
<?xml version="1.0" encoding="UTF-8"?>
<CompanyEmployees version="1">
<Employee>
<Name>John</Name>
<Id>Em234</Id>
<Mobile>09999999999</Mobile>
<AlterMobile>yes</AlterMobile>>
</Employee>
<Employee>
<Name>Ram</Name>
<Id>Em432</Id>
<Mobile>8967452354</Mobile>
<AlterMobile>yes</AlterMobile>
</Employee>
<Employee>
<Name>Raj</Name>
<Id>Em098</Id>
<Mobile>02343235478</Mobile>
<AlterMobile>no</AlterMobile>
</Employee>
그것은 디스플레이의 오류없이. 하지만 내 실수는 어디서 무엇인지 알 수 없었습니다. 아무도 찾지 않으면 나에게 친밀 해주십시오.
는
나는 이해하지 못합니다 ... 1. 무엇을 필터링하려고합니다. 2. 필터 함수에서 "항목"매개 변수를 사용하지 않는 이유는 무엇입니까? 3. 예상되는 결과는 무엇입니까? 떨어진 코드가 도움이되지 않습니다. O –