The JSON coming back from the server (used for populating the dataTable) looks like:
[
{
"id":1,
"attributeType":{
"id":1,
"name":"test1",
"tag":"test-type",
"is-dog":false
},
"attributeValue":{
"id":null,
"name":"blah",
"tag":"BLAH"
},
"buzz":1,
"fizz":"53abc"
}
]
However, I only want to display the following fields:
idattributeValue.namebuzz
And furthermore, I want them displayed in the following order (left to right):
buzzattributeValue.nameid
How can I configure my dataTable to select only these three fields, and to display them in the desired order? Thanks in advance!
What you could do to achive this is build your table dynamically and then send this to the datatable.
In the following example I am assuming the Json is coming back in a jQuery Ajax call and you have multiple items in your response:
In your View you would have:
One thing to bear in mind is that I had problems if I placed the
$('#datatableContent').dataTable({ });config part outwith the success of the ajax call. I have mines placed after the$("#datatableContent").append(buildTable);line within the success and it works perfectly every time.