$(document).ready(function() {
var oTable = $('#example').dataTable({
"aoColumns": [
{"mData": "name"}
]
});
// Sample model
var Person = function() {
this.name = null;
};
p = new Person();
// Add first row.
oTable.fnAddData(p);
// Try first update.
oTable.fnUpdate( {name: 'hardcoded'}, 0 ); // <--- Works
// Change the name property.
p.name = 'updated';
oTable.fnUpdate( p, 0 ); // <--- Doesn't work
} );
I can't get this to work, when i run the oTable.fnUpdate( p, 0 ); i am getting
Uncaught TypeError: Cannot call method 'fnSetData' of undefined
Why?
$(document).ready(function() {
var oTable = $('#example').dataTable({
"aoColumns": [
{"mData": "name"}
]
});
// Sample model
var Person = function() {
this.name = null;
};
p = new Person();
// Add first row.
oTable.fnAddData(p);
// Try first update.
oTable.fnUpdate( {name: 'hardcoded'}, 0 ); // <--- Works
// Change the name property.
p.name = 'updated';
oTable.fnUpdate( p, 0 ); // <--- Doesn't work
} );
I can't get this to work, when i run the oTable.fnUpdate( p, 0 ); i am getting
Uncaught TypeError: Cannot call method 'fnSetData' of undefined
Why?
Share Improve this question asked Oct 19, 2013 at 13:29 brazorfbrazorf 1,9612 gold badges32 silver badges55 bronze badges1 Answer
Reset to default 3Use a proper object to initialize persons. Then you can use later fnUpdate with an object call like you did
var p = {
name: null
};
See here for full code: jsfiddle