AndrewMcLagan
AndrewMcLagan

Reputation: 13987

Yahoo YUI DataTable.DataSource, anyway to simple update?

Is there a simple way to update a DataTable through a request rather then having to request the entire result set again?

currently im doing this:

    // register add modules event
Y.one('#add_modules').on('click', function(e) {

    e.preventDefault();

    table.datasource.load({ 
        request: 'module_id=' + Y.one('#model').get('value') + '&module_count=' + Y.one('#module_count').get('value') + '&array_id=' + <?php echo $pv_array->id; ?>
    }); 
}); 

Although this removes any existing data and populates the table with the request result where as i want to simply "update" the table rather then having to request the whole result set again.

Upvotes: 1

Views: 336

Answers (1)

Mouna Cheikhna
Mouna Cheikhna

Reputation: 39658

add a new Record to the RecordSet (recordSet is the repository for DataTable data) using recordSet.add method

var item = {}; 
      item.module_id =  Y.one('#model').get('value');
      item.module_count = Y.one('#module_count').get('value');
      item.array_id = <?php echo $pv_array->id; ?>;

//get record set
var rs = table.get('recordset');
rs.add(item); 

Upvotes: 2

Related Questions