Apache flex Flex:如何在AdvancedDataGrid中隐藏行?
我有一个AdvancedDataGrid,它的数据提供者是ArrayCollection。例如,我有一个复选框,允许我显示或隐藏AdvancedDataGrid中的某些行Apache flex Flex:如何在AdvancedDataGrid中隐藏行?,apache-flex,advanceddatagrid,show-hide,invisible,Apache Flex,Advanceddatagrid,Show Hide,Invisible,我有一个AdvancedDataGrid,它的数据提供者是ArrayCollection。例如,我有一个复选框,允许我显示或隐藏AdvancedDataGrid中的某些行 你知道我该怎么做吗?我的建议是使用数据提供程序的filterFunction属性。基本上,您可以为数据提供程序提供一个函数,该函数将确定ArrayCollection中的给定项是否被排除(如果某个项被排除,它将不会显示在AdvancedDataGrid中,本质上使其“不可见”)。可以找到filterFunction的文档 然后
你知道我该怎么做吗?我的建议是使用数据提供程序的
filterFunction
属性。基本上,您可以为数据提供程序提供一个函数,该函数将确定ArrayCollection中的给定项是否被排除(如果某个项被排除,它将不会显示在AdvancedDataGrid中,本质上使其“不可见”)。可以找到filterFunction
的文档
然后,我建议选中复选框在数据提供程序中的对象上设置一个属性,然后由筛选函数使用该属性包括/排除行。以下是一些(非常粗略的)伪代码:
private function checkboxClickHandler( event:MouseEvent ):void
{
/*
Based on the MouseEvent, determine the row
in the data grid you're dealing with
*/
myDataProvider[someIndex].checkboxFlag = myCheckBox.selected;
myDataProvider.refresh(); // calling refresh() re-applies the filter to
// account for changes.
}
private function myDataProviderFilterFunction( item:Object ):Boolean
{
// assuming we want the item to be filtered if checkboxFlag is true
return !item["checkboxFlag"];
}
我的建议是使用数据提供程序的
filterFunction
属性。基本上,您可以为数据提供程序提供一个函数,该函数将确定ArrayCollection中的给定项是否被排除(如果某个项被排除,它将不会显示在AdvancedDataGrid中,本质上使其“不可见”)。可以找到filterFunction
的文档
然后,我建议选中复选框在数据提供程序中的对象上设置一个属性,然后由筛选函数使用该属性包括/排除行。以下是一些(非常粗略的)伪代码:
private function checkboxClickHandler( event:MouseEvent ):void
{
/*
Based on the MouseEvent, determine the row
in the data grid you're dealing with
*/
myDataProvider[someIndex].checkboxFlag = myCheckBox.selected;
myDataProvider.refresh(); // calling refresh() re-applies the filter to
// account for changes.
}
private function myDataProviderFilterFunction( item:Object ):Boolean
{
// assuming we want the item to be filtered if checkboxFlag is true
return !item["checkboxFlag"];
}