I have a custom itemrenderer for a datagrid's column that contains a
dropdownlist (DDL). This DDL is populated with a set of numbers starting
at 1 and stopping at the length of the itemrenderer's datagrid
dataprovider's length (i.e. 1 thru 20). I then have the DDL'S
selectedIndex set to the row number in which the DDL appears. So,
looking at the datagrid, first row is set to 1, second row to 2, etc.,
etc. The DDL is being populated correctly as well as its
selectedIndexes. This is all being handled in the prepare function of
the itemrenderer.

The issue comes in when I go to change the DDL's value, if I scroll the
datagrid, or mouse back over the DDL, the value of the DDL reverts back
to the original value. I am pretty sure this has something to do with my
code and the fact that it's been handled in the prepare function as well
the itemrenderers being recycled(?). I am just not sure how to resolve

I have included the prepare function code below:

             override public function
prepare(hasBeenRecycled:Boolean):void {

                 if(data != null) {

                     // grab datagrid reference;
                     dg = DataGrid(owner);

                     // since prepare() is called several times only
populate list_ac
                     // to length of dg dataprovider.length;
                     if( list_ac.length != dg.dataProvider.length){

                         for(var i:int=0;i< dg.dataProvider.length;i++) {



                     // set selected index of dropdownlist(ddl) for
'this' itemrenderer
                     // to match location in row of datagrid(dg);
                     for(var j:int = 0;j<dg.dataProvider.length;j++){

                         if(data.question_id == 

                             ddl.selectedIndex = j;




Please let me know if anything is unclear as I tried to make it as
straightforward as possible. Thanks, in advance.

Reply via email to