View Full Version : cellpress event loads movieclip

06-10-2005, 05:32 PM
i m getting x and y property of the selected row in a datagrid which are visible but when i scroll and go down x and y value of the rows which were not visible before scrolling is coming out as "undefined".

if i reduce the rowheight and the whole data is fitted in the grid, its working fine but the moment scroll bar comes rows which are below giving undefined value

trace( datagrd.rows[rowNum]._y)

plzz help :confused:

06-10-2005, 05:35 PM
Wow, I have absolutely no idea what you're talking about. Maybe if you attach the zip or post your code I'd understand. Or maybe someone else here does understand what you're saying and its my fault :O

06-10-2005, 05:37 PM
yes, please try to use more descriptive thread titles as well. They will help your question be answered sooner and by the right person.

06-10-2005, 05:46 PM
It's goes like this...
I have a datagrid and I had attached a XML file with this Datagrid.My XML File create 20 rows in Datagrid.Datagrid size(rowCount property) allows to display 3 rows at a time and if more rows are there then vertical scroll get displayed.Since in this case i get a scroll bar on my grid as I have 20 rows to display.
I have placed a trace as trace(my_dg.rows[rownum]) where rownum is event.itemIndex in my datagrid cellpress event.
On click of Cell in present displayed rows i.e 1 to 3 rows returns me "Object" but if I hit the vertical scroll bar in my datagrid and again press the cell in the new displayed rows i.e 4 to 6 rows ,then the trace returns "undefine".
But One thing which is very weird is if i write trace(my_dg.rows[rownum].getItemAt(cellindex).columnname) it return me value for all disaplyed rows i.e wether its 1 to 3 ot 4 to 6 .
My basic requirement is to get X and Y position of current display rows


09-06-2006, 04:28 AM
I'm not sure I understand exactly what you're after, but, since your "basic requirement is get the x and y position" you could use a cellpress listener. The one below is from Flash 8 help file. Notice that it gives you the value of "evt_obj.columnIndex" (column number), and "evt_obj.itemIndex" (row number). The rowCount property won't return the position of a row, only the number of visible rows in the datagrid.

// Set up sample data.
my_dg.dataProvider = [{name:"Clark", score:3135}, {name:"Bruce", score:403}, {name:"Peter", score:25}];

// Create listener object.
var dgListener:Object = new Object();
dgListener.cellPress = function(evt_obj:Object) {
var cell_str:String = "("+evt_obj.columnIndex+", "+evt_obj.itemIndex+")";
trace("The cell at "+cell_str+" has been clicked");

// Add listener.
my_dg.addEventListener("cellPress", dgListener);