Adding empty column to a table
Adding empty column to a table
I have object based data source and I need to add empty column for edit / delete buttons. I have tried to do something like this article teaches - http://datatables.net/release-datatables/examples/ajax/null_data_source.html, but it didn't work.
How can add it?
Data:
[code]
{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData": [
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
},
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
},
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
}
]
}
[/code]
JS:
[code]
$(document).ready(function() {
$('#table_id').dataTable({
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bSort": true,
"sAjaxSource": "/users",
"aoColumns": [
{ "mData": "userid" },
{ "mData": "password" },
{ "mData": "status_id" },
{ "mData": "created" }
]
});
});
[/code]
How can add it?
Data:
[code]
{
"sEcho": 1,
"iTotalRecords": "57",
"iTotalDisplayRecords": "57",
"aaData": [
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
},
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
},
{
"userid": "tM4Ga0zX",
"password": "ZKwMEiIa",
"status_id": 0,
"created": "2014-02-11 09:29:02"
}
]
}
[/code]
JS:
[code]
$(document).ready(function() {
$('#table_id').dataTable({
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
"bSort": true,
"sAjaxSource": "/users",
"aoColumns": [
{ "mData": "userid" },
{ "mData": "password" },
{ "mData": "status_id" },
{ "mData": "created" }
]
});
});
[/code]
This discussion has been closed.
Replies
There is an example of the type of table you describe here: https://editor.datatables.net/release/DataTables/extras/Editor/examples/inlineControls.html . Obviously the example uses Editor, but if you look at how the last column in the table is created, you'll be able to see how to use sDefaultContent to add static content to a table.
Allan