> Hi,

Hi there.


> I've data bound my array collection to the datagrid, but how do I populate
> the dataField of the data 

> grid columns in the datagrid.


Just make sure that the value object class is decorated with a [Bindable]
metadata tag. Any changes to the objects in the collection should now be
reflected in your datagrid assuming proper configuration is used when
declaring the datagrid. The way it is normally done is to create a
pre-populated collection of Objects and then set the dataProvider property
of the datagrid to this collection.


> If i was using public properties in my value objects, then putting the
> property name in dataField would 

> work, but I'm using private properties so can't access them, I'd like to
> know how to access getters and 

> setter properties when databinding like this.


You can expose the private fields of your value object by providing
appropriate getters and setters. E.g.


[Bindable]
public class Person
{
  private var _name:String;

  private var _age:Number;

  public function get name():String
  {
    return _name;
  }

  public function set name(value:String):void
  {
    _name = value;
  }

  public function get age():Number
  {
    return _age;
  }

  public function set age(value:Number):void
  {
    _age = value;
  }

}

And use it like:

var p:Person = new Person();
p.name = 'me';
p.age = 666;


> Thanks

> Stephen


HTH,
sasuke
-- 
View this message in context: 
http://old.nabble.com/Populating-a-datagrid-with-a-ArrayCollection-of-VO-that-use-getters-setters-tp26286246p26287356.html
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to