Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you select a row inside a datagrid? 1

Status
Not open for further replies.

sarcus25

Programmer
Apr 14, 2005
27
0
0
Hi just trying to select a row in a datagrid so that it's highlighted. I need it to select the row that contains the song being played. I can find out what song is being played just need to know how to select the row. Thanks in advance.

Code:
songList.onLoad = function(bSuccess):Void{
	if (bSuccess){
		//Select the song in the datagrid 
                //being played and highlight in green
		
	}
}
 
mx 2004 solution.....may be easier with flash 8

you have to mess around alternating row colors


songList.setStyle("alternatingRowColors", getRowColorsArray(songList, 1, 0xff00ff, 0xF3F3F3));

1 sets it to first row....change this to the selected song.....easy enough to capture

Code:
function getRowColorsArray(grid:DataGrid, rowIndex:Number,
                           rowColor:Number, defaultColor:Number):Array {
    var rowColors:Array = new Array();
    var l:Number = grid.getLength();
    for (var i:Number = 0; i < l; i++) {
        if (i == rowIndex) {
            rowColors.push(rowColor);
        } else {
            rowColors.push(defaultColor);
        }
    }
   
    l = grid.getRowCount();
    for (i = rowColors.length; i < l; i++) {
        rowColors.push(defaultColor);
    }
   
    return rowColors;
}

 
Actually found an easier way to do this after much searching. Works in flash 8. Not sure about MX.
Code:
grid.setPropertiesAt(indexNumber,backgroundColor:0x404040});

just like me simple ;)
 
No actually i am using it with the datagrid here. The datagrid is an extension of the list component.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top