spark list- bindable setter not working?
hello,
i have xml node bound custom variable in custom list component itemrenderer (called shelveslist) so:
[bindable]
public function set selectedid(id:number):void{
var i:number = 0;
each (var item:* in dataprovider){
if(item.@id == id){
selectedindex = i;
}
i++;}
}
public function selectedid():*{
return selecteditem.@id;
}
and in app have this:
<components:shelveslist id="shelves" selectedid="@{bookmodel.book.shelf_id}"/>
where bookmodel xml object.
what strange when change bookmodel.book.shelf_id not update shelves.selectedid. if remove [bindable] setter update bookmodel.book.shelf_id.
however, if [bindable] removed setter , change selectedid, not update bookmodel.book.shelf_id, though have two-way binding set.
is bug or overlooking obvious? thank help.
nevermind, figured out! need set [bindable] on getter, , add en event handler on change:
[bindable("selectedidchanged")]
public function selectedid():*{
return selecteditem.@id;
}
public function set selectedid(id:number):void{
var i:number = 0;
each (var item:* in dataprovider){
if(item.@id == id){
selectedindex = i;
}
i++;}
}
protected function setselectedid(event):void{
selectedid = number(selecteditem.@id);
dispatchevent(new event("selectedidchanged"));
}
then on change event, use setselectedid. -b
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment