2 Replies Latest reply on Mar 31, 2010 5:21 AM by TomBurgundy

    setting the selected index of a datagrid-component

    liquid8x Level 1



      I was suprsised to find out that there seems to be no built in method to set a datagrid's selected index(?)

      I have been googling about this and this is what I've done so far:


              private function setDatagridIndex(selectedHeader:String):void
                  var gData:Object = uutisdg2.dataProvider;
                  for(var i:Number=0; i < gData.length; i++)
                      var thisObj:Object = gData.getItemAt(i);
                      if(thisObj.otsikko == selectedHeader)
                          uutisdg2.selectedIndex = i;


      This function takes the selected row's string-value as a input parameter. The if-clause seems to work (loop finds the correct row).

      But the selection of a row does not work yet, I can't figure out what I'm missing here. I understand that the way to go is to loop through all the values in the datagrid and then set the correct index in that loop.