Child rows without the parent tr&td

Child rows without the parent tr&td

DiederikDiederik Posts: 2Questions: 0Answers: 0
edited March 2014 in DataTables 1.10
Hey!

Thanks for making this awesome plugin. It makes life a lot easier :).
However, I do have a problem. I am trying to do something similar to this:

http://live.datatables.net/yasitig/1/edit?html,js,output

But as you can see, the formatting is off. How is this?
Furthermore: can you confirm whether this is the correct approach?

The way I am using it is in a Content Management System backend, where some pages have child pages.
These are all outputted in the table, and trough jQuery I save them in an array, remove them from the dom and then later I add them using the row.child.show () function. However, I think that this might be a very inefficient way of doing this. Here is a screenshot of what I am trying to approach:

https://www.dropbox.com/s/qft8d4psq2d0blr/Screenshot%202014-03-05%2020.19.37.png

Would it maybe be possible to provide this data in JSON or something like this:

[code]
{
"1" : { "Lorem" , "24-02-2014 14:20" , "" , "24-02-2014 14:20" , "children" : {
{ "Lorem" , "24-02-2014 14:20" , "" , "24-02-2014 14:20" }
{ "Lorem" , "24-02-2014 14:20" , "" , "24-02-2014 14:20" }
} }

"2" : { "Ipsum" , "24-02-2014 14:20" , "" , "24-02-2014 14:20" , "children" : { } }

}
[/code]

Finally: is it possible to also search trough child rows?

Replies

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    There is a bug in the 1.10 code at the moment that is causing that rendering error. I will look at it as soon as I get ingot he office tomorrow as it was highlighted else where as well...

    The one thing that concerns me about the general approach you have taken here is the child row is actually a 'host' row in the DataTable - i.e. it is a 'real' row - not a child one.

    If you wanted to have a child row, like this, then the approach I would suggest is actually much like your JSON example above - with one exception - you must give DataTables an array of objects, not an object of objects!

    I'll fix the bug tomorrow morning and bash a quick example together.

    Allan
  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Just spotted this bit:

    > Finally: is it possible to also search trough child rows?

    No. Child rows do not have searching or sorting applied to them. For that detail to be used on the rows, they must be 'host' rows in the table.

    Allan
  • DiederikDiederik Posts: 2Questions: 0Answers: 0
    Dear Allan,

    Thank you for your reply.
    Thank you for confirming that the rendering error is a bug in the plugin. Furthermore I will look into the JSON solution.

    Too bad that searching through child rows is not possible. Sorting I don't really care about, but it would be great if searching would work. Deriving from your answer this is not a feature that will be added in the future, is this correct?

    Best regards,

    Diederik
  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Here is an example showing the data structure you gave above (modified a little to be valid JSON) with the child rows being shown (I've put the fix into DataTables!): http://live.datatables.net/hihikem/1/edit .

    > Deriving from your answer this is not a feature that will be added in the future, is this correct?

    It will be, but not for a long time to come I suspect! That is going to be the corner stone of DataTables 2, but I've still got plans for 1.11 and 1.12 first..

    The closest you can get at the moment is to add the child rows as "parent rows", but us DataTables sorting abilities to force these rows to stay together. It is possible that way, but it requires the data to be preprocessed. It also won't be smart enough to do things like hiding the child rows when the parent is filtered out.

    Allan
This discussion has been closed.