Editor and child-row - Where to begin
Editor and child-row - Where to begin
I have joined tables in a one to many relationship. I want to put the many occurrence in a child row like in the custom display controller example, I started on the dataTables example first and it looks simple, but I cannot for the life of me figure out how to do that with Editor in the mix. Due to the size of my tables, I have to be server side. Can someone point me in the right direction? I would even be happy to have a link that creates a separate table in the table and make a separate editor for that instance.
This question has accepted answers - jump to:
Answers
I have the data coming over in an array called notes. I have the empty column but the words [object Object] are in front of the image. It even adds a child row when clicked but says unset in the fields I want to show. I did a DataTables debug at http://debug.datatables.net/iqixon .
I think I can lick this thing, but several hours later and multiple attempts. I can't seem to get hold of the data. How do I get it into a child row?
this function is where the problem is
I can see the array called notes with the proper data in firebug. All I get is undefined. Everything is there but the data. The table layout and everything else shows up in the child row.
Hi,
Thanks for the link to the debug trace. I see that your JSON data for each row is passing through a
notes
array of objects. That is the data you want in yourformat()
function presumably.So when you call
format()
how are you doing that?format( row.data().notes )
or something like that?Looking at your
format()
function above you are treating it as an object, rather than as an array. You'll need to loop over the array to get all of the notes from it (so you would usenotes[i].type
for example (wherei
is the loop counter).Regards,
Allan
Thanks again for the response.
I was using the same method as in your examples. Once I figured out how to grab some of it, I was going to start the process of trying to process the array. (no real idea on that either)
A newer debug - http://debug.datatables.net/ecavaj
I tried the notes[i].type before with no luck. Actually it threw errors saying undefined, while neither is it the way it is now. I could tell it was an object even though I thought the array join instructions said it would be an array.
The way I am getting the array is here:
Okay - good. So you are using
format(row.data())
to pass in the either row of data into theformat()
function.So if you were to add
console.log( notes )
in that function, on the console you would see the data object for that row. It has anotes
array - so you access the notes you would use:(you might want to change the
notes
variable name to make things easier!).Then you can loop over that making the HTML required.
Regards,
Allan
Thanks - getting closer. Figured out where to put the console.log and it is working. Notes is defined! Woo hoo. Just have to figure out how to loop over it now.
for ( var i=0, ien=noteArray.length ; i<ien ; i++ ) { ... }
:-)Allan
The dance of joy is about to be performed around my desk! Thank you sir!
Great piece of software you have here.
Now to make the contents editable...