how to use the data of nested objects (arrays) in server-side processing
how to use the data of nested objects (arrays) in server-side processing
AndriiFK
Posts: 5Questions: 1Answers: 0
how to use the data of nested objects (arrays) in server-side processing, or is it possible to somehow refer to two columns in one $('#myTable').DataTable({
'ajax': {
url: '/fetchData.php',
},
'columns':[
{
data: 'file',
},
{
data: 'name', data: 'id', <============ ???
render: function(data, ... ???... type, row)
},
'processing': true,
'serverSide': true
});
This question has an accepted answers - jump to answer
Answers
You can't define two
columns.data
for the same column.This example shows how to display nested objects.
This example shows how to combine row data to be displayed in one column.
If this doesn't help then please post an example of your JSON data from the browser's network inspector tool. Tell us how you want it displayed.
Kevin
as I understand these Ajax applications. but I asked about the ServerSide method
Kevin is correct - use a rendering method on the client-side to combine two data points returned from the server. There is an example of that available here - the
first_name
andlast_name
properties returned from the server are combined to be shown in the first column.If you wanted to combine the data at the server-side, you'd need to modify whatever
fetchData.php
is doing.Allan
Just to make sure I understand your question:
You are getting a JSON response from the server, using server side processing, and want to display the returned data in a certain way. Is this correct? If yes then the above answers still apply.
Kevin
json ajax
creating a table ajax
It works but rendering is slow and server side rendering is very fast. So I want to do it on the server side , but I can't pass several parameters to the rendering of that column
because the json file has a different look
creating a table SERVER SIDE
how should I pass two DATA parameters in the column ?
if for ajax I create a corresponding json file, then for the method on the server side I do not understand how to edit fetchdata.php so that the json file at the output is in the desired form
Use:
With that
data
will be whatever the value ofs_opys
is. Therow
property is the data object for the row - i.e.s_opys === row.s_opys
. So you'd userow.id
to get the id for the row, etc.Allan
Thank you very much. I forgot something about it.