JSON formats and Columns

JSON formats and Columns

abiieezabiieez Posts: 8Questions: 2Answers: 0
edited October 2012 in General
My html code for table is as follow

[code]










[/code]

I initialize datatables by using the following code

[code]

$(document).ready(function() {
$('#tableListing').dataTable({
"bAutoWidth" : true,
"bProcessing" : true,
"bServerSide" : true,
"sAjaxSource" : '${actionUrl}'
});
});
[/code]

I have two formats of JSON as below

[code]
{"creationTime":0,"enabled":false,"id":105,"loginDuration":0,"online":false,"password":"asdasd","userName":"asd1212123"}

and

[1,"abiieez",true]

[/code]

Only the second JSON format is acceptable by my datatable, I believe this because of the number of columns have matched. How can I make my datatables can accept the first JSON format eventhough I am only gonna show three columns only ?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    edited October 2012
    DataTables can accept almost any JSON format - see http://datatables.net/blog/Extended_data_source_options_with_DataTables .

    Also note that if you want to use server-side processing (bServerSide) you MUST implement that DataTables server-side processing protocol: http://datatables.net/usage/server-side .

    Allan
  • abiieezabiieez Posts: 8Questions: 2Answers: 0
    Hi Allan thanks for your response. Basically I don't want to hardcode the columns names in the server since different object will have different number of columns.

    Is there a way for me to pick which column I would like to show on the client-side ?
This discussion has been closed.