DT Editor: How do I get the old,newly edited data along with the entire row in the data table?
DT Editor: How do I get the old,newly edited data along with the entire row in the data table?
Hi,
I am using datatable editor to let users modify certain columns in the table. I call a function within editor ajax which creates and runs a python task that will make changes to the backend database and print contents back to the data table. I am bit confused on how to use it properly as this is my first time.
Here is the snippet of my code -
editor = new $.fn.dataTable.Editor( {
table: "#cau_table",
fields: [ {
label: "Component",
name: "component"
},
{
label: "Version",
name: "version"
},
{
label: "License",
name: "license"
},
{
label: "Usage",
name: "usage"
}
],
ajax: function (method, url, data, success, error) {
testme(data.data.undefined) ==> this is giving me an object with data->data->undefined->version->new_data **
}
});
var cau_tab = $('#cau_table').DataTable({
'data': [],
'columns': [
{'data':'component'},
{'data':'version', editField: "version"},
{'data':'license'},
{'data':'usage[, ]', editField: "usage"}
],
'pagingType':'full_numbers'
});
cau_tab.on( 'click', 'tbody td', function (e) {
editor.inline( this, {
buttons: { label: '>', fn: function () {
this.submit()}
}
});
} );
** Here I also need to send the old data, basically other fields in that row of the modified one.
How do I get that data?
Thanks,
Sushma
This question has an accepted answers - jump to answer
Answers
If you are using Editor 1.5, when you use Inline editing, only the field that you changed is included in the payload to the update mechanism.
You can pull along the full data set for your reference by hooking into the OnClick event of the td and grabbing all that row data. It ends up in a different structure than if you used the full editor, but it is available.
Thank you Thom! That works.