0

I am using the datatables from YUI 2.8.2 and its widgets to edit a datasource (YAHOO.example.Data.response) as follows:

    this.bpDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.response);
    response_datasource = this.bpDataSource;
    this.bpDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
    this.bpDataSource.responseSchema = {
        resultsList: "item_evaluacion",
        fields: [ ... ]
    };
    this.standardSelectDataTable = new YAHOO.widget.ScrollingDataTable("div_item",
        bpColumnas, this.bpDataSource, {height:"9em"} );

I want to retrieve the edited data from this datatable and proccess it. I tried a variable pointing to this.bpDataSource first but this variable contains only the original datasource without the changes the user made. How can I retrieve the updated version of my datasource?

richardtk_1
  • 751
  • 3
  • 11
  • 33

1 Answers1

1

The DataSource only retrieves the data but does not keep a reference to the data retrieved. Once it has passed the retrieved data to whatever requested it, in this case DataTable, it forgets about it. DataTable then keeps the data in the RecordSet collection, which is composed of individual Record instances where you can fetch the values by field name. For some funny reason, the API docs for both Record and RecordSet are not under DataTable. I know the docs for those two are somewhere in there, but they somehow got filed under some other component.

Anyway, in DataTable, you have method getRecord() which takes an index. You can loop through it until it returns null or undefined. Otherwise, I believe you could do getRecordset().getLength() and use that to iterate with a for loop. Then, on each record instance, method getData() takes the column key and returns the value.

For more information read the two 'Working with the DataTable widget' articles referenced in the heading of DataTable.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user32225
  • 854
  • 7
  • 7