Search code examples
actionscript-3apache-flexactionscriptmxml

Flex property binded to datagrid dataProivder array


I have the following datagrid in my application mxml:

<event:SelectRowDataGrid id="resultDG" 
    dataProvider="{model.EventDTOs}"
    ...
    <event:columns>
        ...

SelectRowDataGrid is my extension of the Flex DataGrid:

package xx.xx.xx.xx.event
{
import mx.controls.DataGrid;

public class SelectRowDataGrid extends DataGrid 
{
    private var _checkedItems:Array;

    public function SelectRowDataGrid() {
        super();
        _checkedItems = new Array();
    }

    public function get checkedItems():Array
    {
        for each (var event:EventDTO in dataProvider) {
            if(event.checked)
                _checkedItems.push(event);  
        }
        return _checkedItems;
    }
}
}

I am trying to set the enabled property of a button like so:

<controls:PrintButton enabled="{resultDG.checkedItems.length>0}"

But I get the followin error when building:

Multiple markers at this line:
-Data binding will not be able to detect assignments to "length".
-checkedItems

What am I missing?


Solution

  • As hinted by Timofei Davydik

    Adding [Bindable] annotation to the class made it happen:

    [Bindable]
    public class SelectRowDataGrid extends DataGrid 
    {
    ...