Limit table results initially and have to 'show all' button to display any additional results

Limit table results initially and have to 'show all' button to display any additional results

browner11browner11 Posts: 2Questions: 1Answers: 0
edited June 2019 in Free community support

First of all, sorry if this has been asked before. I've read through many questions and answers that were close to what I was looking for but haven't found a solution to my specific problem.

Right now I have an 'products' table nested inside an 'orders' table. The products table gets expanded when the user clicks on an order record to display all the products that are a part of that order . I'm looking for a way to display a limited number of product rows upon initialization (for example 5) and then have a 'show all' button that would expand the table to show every product included in the order.

Any suggestions of how I would go about doing this?

I should also mention that I would like to have pageination disabled on this inner nested table

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    Is your inner table an HTML table or a Datatable?

    Assuming the inner table is a Datatable for these answers....

    You can use the dom option to display the page length input and the lengthMenu option to add the all option.

    I would like to have pageination disabled on this inner nested table

    That would leave out the above. You could use scrollY instead.

    If these answers don't help maybe you can provide more details of what you have. A link to your page or a test case would be useful.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • browner11browner11 Posts: 2Questions: 1Answers: 0

    Wow, thanks for such a fast reply.

    My inner table is a Datatable. I just tried using scrollY and it's pretty close to what I'm looking for. Ideally the extra rows outside of the viewport would just be hidden, and could be shown with the click of a button instead of scrolling down to see them.

    I also looked at the lengthmenu example and clicking back and forth between the '10' option and the 'all' option gives the intended effect I'm looking for but without the pagination header and footer. It would just be a button press instead.

    I will look into creating a test case to provide further details.

    Thanks!

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769
    Answer ✓

    You can use the page.len() API with your own button. Something like this:
    http://live.datatables.net/mixisozi/1/edit

    Kevin

This discussion has been closed.