manually change the JSON object before enhancing datatables in order to add extra columns
manually change the JSON object before enhancing datatables in order to add extra columns
florincosmin
Posts: 6Questions: 0Answers: 0
Hi, I have this JSON object that has all the info needed to enhance datatables.
The JSON Object looks like this:
[code]
{
"isDirty": false,
"group": false,
"bAutoWidth": false,
"bDestroy": false,
"bFilter": true,
"bInfo": true,
"bPaginate": true,
"bSortable": true,
"bSortCellsTop": false,
"sDom": "Rlfrtip\u003cā#back1ā\u003e",
"wrapperWidth": 480,
"aaData": [
["10-08-11", "12", "12-2", 576, 17060, 201195.34, 127, 0],
["18-08-11", "12", "12-2", 576, 16380, 197155.76, 128, 0],
["19-09-11", null, "50-1", 697, 19857.53, 212585, 149, 0],
["30-09-11", "10", "10-1", 414, 12560, 152361.18, 131, 0],
["26-10-11", "11", "11-3", 640, 21340, 255769.94, 135, 0],
[null, null, null, null, null, null, "a", 0]
],
"aoColumnDefs": [{
"group": 0,
"aTargets": [0],
"sTitle": "Dato",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "ui-datepicker-inline",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [1],
"sTitle": "Lokation",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [2],
"sTitle": "Batch",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [3],
"sTitle": "Antal grise",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [4],
"sTitle": "Total kg",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [5],
"sTitle": "Total",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [6],
"sTitle": "Id",
"bVisible": false,
"bSearchable": false,
"bSortable": true
}, {
"group": 0,
"aTargets": [7],
"sTitle": "Dirty",
"bVisible": false,
"bSearchable": false,
"bSortable": false
}]
}
[/code]
I call datatables like this:
[code]
window.actTableDefData = JSON.parse(localStorage.getItem("datatables"));
window.oTable = $('#example').dataTable(window.actTableDefData);
[/code]
I want to know if it is possible to change this object (window.actTableDefData) in order to add two columns: edit and delete so that each row can be edited/deleted. If yes, how can I achieve that?
The JSON Object looks like this:
[code]
{
"isDirty": false,
"group": false,
"bAutoWidth": false,
"bDestroy": false,
"bFilter": true,
"bInfo": true,
"bPaginate": true,
"bSortable": true,
"bSortCellsTop": false,
"sDom": "Rlfrtip\u003cā#back1ā\u003e",
"wrapperWidth": 480,
"aaData": [
["10-08-11", "12", "12-2", 576, 17060, 201195.34, 127, 0],
["18-08-11", "12", "12-2", 576, 16380, 197155.76, 128, 0],
["19-09-11", null, "50-1", 697, 19857.53, 212585, 149, 0],
["30-09-11", "10", "10-1", 414, 12560, 152361.18, 131, 0],
["26-10-11", "11", "11-3", 640, 21340, 255769.94, 135, 0],
[null, null, null, null, null, null, "a", 0]
],
"aoColumnDefs": [{
"group": 0,
"aTargets": [0],
"sTitle": "Dato",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "ui-datepicker-inline",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [1],
"sTitle": "Lokation",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [2],
"sTitle": "Batch",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [3],
"sTitle": "Antal grise",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [4],
"sTitle": "Total kg",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [5],
"sTitle": "Total",
"bVisible": true,
"bSearchable": true,
"bSortable": false,
"sClass": "alignRight",
"sWidth": "80px"
}, {
"group": 0,
"aTargets": [6],
"sTitle": "Id",
"bVisible": false,
"bSearchable": false,
"bSortable": true
}, {
"group": 0,
"aTargets": [7],
"sTitle": "Dirty",
"bVisible": false,
"bSearchable": false,
"bSortable": false
}]
}
[/code]
I call datatables like this:
[code]
window.actTableDefData = JSON.parse(localStorage.getItem("datatables"));
window.oTable = $('#example').dataTable(window.actTableDefData);
[/code]
I want to know if it is possible to change this object (window.actTableDefData) in order to add two columns: edit and delete so that each row can be edited/deleted. If yes, how can I achieve that?
This discussion has been closed.