Adding empty column to a table

Adding empty column to a table

lngphplngphp Posts: 22Questions: 0Answers: 0
edited February 2014 in General
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]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I don't see the null data column in your initialisation?

    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
  • lngphplngphp Posts: 22Questions: 0Answers: 0
    Thanks! I got it done!
This discussion has been closed.