tags:

views:

535

answers:

1

Hi, all.

I'm trying to get the contents of a cell in a row in a YUI datatable.

I can use myDataTable.getSelectRows()[0] to get teh first selected row, however, how do I get the contents of the first cell in that row?

Thanks!

+1  A: 

It looks like getSelectRows() returns an array of record IDs. You can retrieve the corresponding record using getRecord(). Once you have a record, use getData() to retrieve the value of the field you are interested in.

var recordID = myDataTable.getSelectRows()[0],
    record = myDataTable.getRecord(recordID);
console.log(record.getData("myField"));

http://developer.yahoo.com/yui/docs/YAHOO.widget.DataTable.html#method_getRecord http://developer.yahoo.com/yui/docs/YAHOO.widget.Record.html#method_getData

lawnsea