fnUpdate row with sAjaxSource
fnUpdate row with sAjaxSource
johncscott
Posts: 14Questions: 0Answers: 0
I initialise a data table as follows:
[code]
$('#teamTable').dataTable( {
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"sLengthMenu": "_MENU_ records per page",
"bProcessing": true,
"sAjaxSource": '/base/Arc/TeamArray/4772/',
"aoColumnDefs": [ { "mRender": function ( data, type, row ) {
return ' ' + data + '';
},
"aTargets": ["tid"]
} ]
[/code]
so the mrender creates two links one of which initialises a cascaded child table and the first launch a modal to editTeam to edit the contents of the row (it's the design) when the modal is cleared I'd like the data in the row in the table to be updated
using the fnFindCellRowIndexes api plugin to find the row from the ID (this works nicely)
I'd then like to update the contents of the row
I'd prefer to do this rather than clear and recall the data source
afaik there is no way to ensure that after the reload the same order / paging / filtering will be in place
and the changed row may not even be visible
but as the button is clicked from within the visible row it seems fair to just update the changed row
[code]
var oTable = $('#teamTable').dataTable();
var row = oTable.fnFindCellRowIndexes(id, 0);
oTable.fnUpdate([tid, NewTeam['Name'], NewTeam['Role'], NewTeam['Manager'], NewTeam['Telephone'], NewTeam['Email'], 0], row);
[/code]
but it seems to not do anything
if update it as a and step through the code on the fourth iteration I get an error
[quote]Update TypeError: Cannot set property '_aData' of undefined[/quote]
if i change it to update only a single cell then nothing at all happens
i've checked the variables in the last line above all exist and are the same type as the original input
any ideas ?
(sorry can't link to the broken page as it's within an intranet behind a firewall)
[code]
$('#teamTable').dataTable( {
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"sLengthMenu": "_MENU_ records per page",
"bProcessing": true,
"sAjaxSource": '/base/Arc/TeamArray/4772/',
"aoColumnDefs": [ { "mRender": function ( data, type, row ) {
return ' ' + data + '';
},
"aTargets": ["tid"]
} ]
[/code]
so the mrender creates two links one of which initialises a cascaded child table and the first launch a modal to editTeam to edit the contents of the row (it's the design) when the modal is cleared I'd like the data in the row in the table to be updated
using the fnFindCellRowIndexes api plugin to find the row from the ID (this works nicely)
I'd then like to update the contents of the row
I'd prefer to do this rather than clear and recall the data source
afaik there is no way to ensure that after the reload the same order / paging / filtering will be in place
and the changed row may not even be visible
but as the button is clicked from within the visible row it seems fair to just update the changed row
[code]
var oTable = $('#teamTable').dataTable();
var row = oTable.fnFindCellRowIndexes(id, 0);
oTable.fnUpdate([tid, NewTeam['Name'], NewTeam['Role'], NewTeam['Manager'], NewTeam['Telephone'], NewTeam['Email'], 0], row);
[/code]
but it seems to not do anything
if update it as a and step through the code on the fourth iteration I get an error
[quote]Update TypeError: Cannot set property '_aData' of undefined[/quote]
if i change it to update only a single cell then nothing at all happens
i've checked the variables in the last line above all exist and are the same type as the original input
any ideas ?
(sorry can't link to the broken page as it's within an intranet behind a firewall)
This discussion has been closed.
Replies
I'd suggest trying to use the DOM node if that is possible, then you don't need to mess around with the DataTables indexes - but it does look like it should work if you just give it `row[0]` .
Regards,
Allan
thankyou