0
votes

I have a class named Student, it has several properties along with the property "isSelected:Boolean"and the class is defined Bindable.

[Bindable]
[RemoteClass(alias="portal::Student")]
public class Student

In an mxml application I have a datagrid in which its dataprovider has been set to an ArrayCollection of Students. I have a column of checkboxex for the datagrid along with a headerItemRenderer checkbox which is supposed to select all the students (all checkboxes in rows should be selected or deselected).

I have defined a handler for the click event of the checkbox in the header which sets the isSelected property of each Student object in dataProvider to false or true. But on click of this check box in the header, I get the warning: unable to bind to property 'isSelected' on class 'Student' and therefore check boxes in rows do not get updated.

I don't get why the binding does not work here and don't know what to do to fix this issue. Any help is greatly appreciated.

3

3 Answers

0
votes

Let your actionscript class extends EventDispatcher (binding is based on event dispatching).

0
votes

It depends, i guess you have somewhere in the code a reference to the student instance, you want to bind on. This reference has to be declared [Bindable] as well, in order to get the binding chain to work.

Also, when you not depend on ActionScript to get the binding to work, you don't have to extend EventDispatcher, because MXML will generate that code for you (with regards to Cosma's comment).

Do you define an inline renderer? This is not the optimum in my opinion, since a component is generated and debugging gets a lil fuzzy, since you might run into scope problems. I'd recommend implementing a new component, implement IDataRenderer and propagate the data to the children through the live cycle or implement the component in MXML. Why IDataRenderer? This interface is necessary.

Also, i'm not sure on that one, but shouldn't it be

    [Bindable]
    [RemoteClass(alias="portal.Student")]
    public class Student {}

?

0
votes

You need to make sure that your ItemRenderer saves the incoming data in a property marked as [Bindable]. You'll want to pass the entire Student in, rather than just "isSelected"...