Child rows implemented as a datatables

Child rows implemented as a datatables

raduborcanraduborcan Posts: 11Questions: 2Answers: 0

Hello,

I am wondering if the child rows could be implemented as datatables themselves, this way beeing able to cascade to as many drilldown subreports (tables).

Thank you

Answers

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739

    Yes, there have been some threads on this subject in the forum. Take a look if you need more details.

    Here is a simple example:
    http://live.datatables.net/sawapoci/1/edit

    It is very rudimentary and is not the best example. One problem with it is it uses the same id for each child Datatable. But it may give you a starting point.

    Kevin

  • colincolin Posts: 1,726Questions: 0Answers: 318

    Hi @raduborcan ,

    Yep, as Kevin said, it's been mentioned a few times. See this thread here, that should help,

    Cheers,

    Colin

  • raduborcanraduborcan Posts: 11Questions: 2Answers: 0

    For me it doesn't work as expected. It shows 3 pairs of identical lines for every child record and above all I cannot figure out how to implement when I have more then one record of child rows (could be hundreds of rows).
    Also I cannot image how can I create for every child row another child rows (something like imbricated drill down subreports).

    Thank you

    Radu B.

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739

    Here is a long winded thread regarding another who wanted multiple levels of Child Rows containing Datatables. The thread discusses some promises issues but I ultimately put this example together using ajax calls to get the data for each Child Row:
    http://live.datatables.net/nokeduka/1/edit

    It utilizes for loops to filter down the data just for the example. If you use ajax calls for the child I suspect you will filter them at the server.

    Again this is just a demo and utilizes the same table ID for each level of children.

    If you have further questions please post an example of what you are doing so we can help.

    Kevin

  • raduborcanraduborcan Posts: 11Questions: 2Answers: 0

    I would like to see the data (/ajax/objects.txt) to figure out a more complex example.
    The second child doesn't resize the viewport as it does the first one, even the script are identical for both... any clue why?
    Is any posibillity to align the childs' fileds with their parents?

    Thank you

  • colincolin Posts: 1,726Questions: 0Answers: 318

    If you just view http://live.datatables.net/ajax/objects.txt you'll get that file. The viewport resize would be specific to Kevin's example/implementation - if you look at the thread I posted above there's another example where that resize doesn't happen.

  • raduborcanraduborcan Posts: 11Questions: 2Answers: 0

    Thank you for the file, but I cannot see how you can scale up for more child records; I've tried putting 3 recs for "extn", but it keeps taking the last one.
    I suppose I have to iterate through the recs somehow, but I don't know how.

    Thanks

    Radu

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739

    Without seeing what you are trying to do its hard to say specifically. There is nothing special about Datatables displaying in a child detail row. You add data to it the same as any other Datatable. You could simply structure your ajax option to request the desired data (using ajax.data and let it populate the table as usual. Since I don't control the server script in my example I needed to use ajax as a function just for the demo.

    Again it depends on the data structure you are receiving and how you want it displayed.

    Kevin

  • raduborcanraduborcan Posts: 11Questions: 2Answers: 0

    Sorry for delay, finally I have some time to test your example.
    I simply added two more rows with "extn" with different values, but it shows only the last value of the field. It appears it ignores the other first two; I suppose it would shown 3 rows with "extn" and their different values.
    Any idea ?

    Thank you

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739

    Hard to say without seeing your code. Please post a test case showing the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • raduborcanraduborcan Posts: 11Questions: 2Answers: 0

    I didn't make any code, just copied yours from http://live.datatables.net/nokeduka/1/edit and in the "objects.txt" file I put 2 more line as I described in previous post. So all the code is there.

    Radu

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739

    Its probably the for loop is no picking up all the rows. I suggest adding console.log statements in the for loop to help debug why its not getting 3 rows of data.

    Kevin

  • kthorngrenkthorngren Posts: 3,284Questions: 19Answers: 739
    edited August 18

    I'm not able to update the objects.txt that is used for the live.datatables.net examples but I did modify the code to display child rows of all records that match the position column. This appears to work and displays multiple rows.

    http://live.datatables.net/yetuyija/1/edit

    I built the example this way because I don't have control of the server scripts and data. It fetches all the data with the child ajax request. In production you probably won't have the child request all the data but filter it using the ajax data option and eliminate the for loop.

    Kevin

Sign In or Register to comment.