childRow on second Page

childRow on second Page

evaLautevaLaut Posts: 11Questions: 4Answers: 0

Hey :-)

maybe someone knows my problem or knows how to fix it.

I have a large dataTable with 120 rows and each row should have a child row. The dataTable pageLength is set to 25, so i got a lot of pages.
And every time the parent row is shown, the dependent child row should be visible, too,

Does someone has an idea, why the child rows just exist for the first 25 parent rows, and aren't created for the other rows on the other pages?

It's difficult to show an example for debugging, because i use the velocity context, to get the data for the different rows.
I have an example there : https://codepen.io/anon/pen/pbjqQm
but the dataTable doesn't work on this page, because of the velocity context. But possibly someone can find the mistake in my javascript code.

I'm very thankful for some help :-)

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49
    edited June 2016

    You might have to add https://datatables.net/reference/event/page event and with each page change, perform the logic to add/show child rows.

  • evaLautevaLaut Posts: 11Questions: 4Answers: 0

    Hey thanks for the answer. I added the code: "paging": true, but i couldn't recognised any changes...
    At the moment, i have 243 different rows, including the child rows. If i set the pageLength to 250 it works perfectly, but if i change the pageLength to 25 the child rows doesn't work anymore...
    How can that be? :-S

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    Then there must be a bug in your code. If you look at https://datatables.net/examples/api/row_details.html example.

    1. expand the first row
    2. change page length
    3. change to page 2 then back to page 1

    Notice how the child row remained in all cases. Once the child row is shown, it should stay. Unless you are blowing up your table and readding all rows, which would remove any child rows.

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    Alright I actually took a look at your example and I don't believe you are adding child rows correctly. Child rows should not be added to the HTML initially but by using the DataTables API.

This discussion has been closed.