Child Row - Data object "d"?
Child Row - Data object "d"?
FD1234
Posts: 4Questions: 1Answers: 0
Hey,
This is a complete noob question, but.... I'm trying to install child rows on a table. I'm following the example here (https://datatables.net/examples/api/row_details.html), but I can't work out what to replace "d" with in the first ,js function.
Code here: https://jsfiddle.net/dpgwqxL9/#&togetherjs=LacK5nTenu
My apologizes for the stupid question!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
d
is the data object for the row. You have first_name, surname, level, email defined as columns. Are you returning other data from your query that you want to display in the child row?In line 6 you need to add the
d
back to look like this:Lets say you are retuning shoe_size and harness_size in addition to the above 4 columns. You can display those in the child row with the following:
If you need further help please post an example of the data you are returning and what you want in the child row.
Kevin
Hi Kevin,
Thanks for the quick reply,
I have 6 objects (First_name , Surname, Level, student_id_number, email & assessor ). I want all 6 displayed in the child row, but only the first three to be displayed in the main table.
I have updated the JS file (and the fiddle one) with your suggestion, by adding the 'd ' and all 6 objects to the format function. However the child row is still not displaying...
In addition to that, I have added a blank column in the HTML page, plus the remaining JS as suggested by the example file.
Advice going forward would be very helpful..
I'm not seeing any data in the table. However I think I see an issue in line 108. You have
#climbing
. I think selectors are case sensitive. Try changing the line to this:Kevin
Hey,
Sorry, the ajax is pulling an internal database to the server. (http://nuigmc.com/climbing_database/index.html)
I fixed the case edit, well spotted! But still no joy
You have a syntax error:
table.Climbing.js:100 Uncaught SyntaxError: Unexpected token {
You need to add a comma.
Kevin
Hey Kevin,
Thanks for help but I decided to leave the child row feature for the time being. I don't have enough experience with the system to get it working right.
Thanks again for your help
I have the same issue and I don't know if anyone understood the question.
What do i replace d with to get my chilrow data from my second table.
Example:
Main DataTable is Department and then in child rows i want all Employees.
I'm getting my Department table as it's my main table, but all Employees data is undefined.
'<td>Show size:</td>'+
'<td>'+d.show_size+'</td>'+
Is not getting filled with the expected data. I would except to do something like Model.Employee.Name instead og at least have the d replaced with a relevant data source somehow?
Anyone still on this? And understand the problem?
It would help to understand your data structure. Is the data from the second table returned with the query response of the first table?
Maybe you can post examples of your data structure.
If the first line of the format function you can use
console.log(d);
to see whatd
is then maybe you can workout how to display the desired data.Kevin