set page length and turn off pagination

set page length and turn off pagination

eoinmcglynneoinmcglynn Posts: 4Questions: 1Answers: 0

Hello,

I want to set the pagelenght to 10 rows, but I also want to turn off pagination. This is an intro table. The full data set is displayed on a second page. I have the options set as below. It seems I can have either, no paging or set a pagelenght, but not bith

"paging": false, "pageLength": 10,

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @eoinmcglynn ,

    Yep, a page contains a number of rows, so with DataTables they come hand-in-hand.

    What is it you're trying to do? Is it just to display the first 10 rows and ignore the rest? If you could explain the problem, we may be able to offer an alternative solution,

    Cheers,

    Colin

  • eoinmcglynneoinmcglynn Posts: 4Questions: 1Answers: 0

    Hi Colin,

    thanks for gettng back.

    I want to show only the first 10 rows after applying a sort. I have set as follows (as mentioned it doesn't work)

    "order": [[ 3, "desc" ]],"searching": false, "paging": false, "pageLength": 10, "lengthChange": false,

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I see, so only ever the first 10 records of your search, and the user is never able to apply their own search or order?

  • eoinmcglynneoinmcglynn Posts: 4Questions: 1Answers: 0
    edited May 2018

    Ideally, they can order the 10 results (but if not, no problem,its only 10 lines and the default sort will be sufficient).

    To add some additional context, this table is part of a "dashboard" style page. The 10 entries will be most recent completed transactions of another process.

    there is a second page where the table is searchable. That works fine :smiley:

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Thinking about it, with my 4 year old rabbiting on beside me in the bath so my thoughts aren't the clearest, I would be tempted to make this table hidden (either by css or jQuery), then, in the initComplete, copy the top ten rows into another, visible table. Any other way is likely to give headaches I suspect. Hope that makes sense, I should be able to knock out a prototype first thing in the morning if you're struggling...

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited May 2018 Answer ✓

    Morning, take a look at this example here - would something like this work? This is copying into a second table - so you get all the benefits of the DataTable (ordering, searching though it's disabled), without worry about hiding the other records.

    If your hidden table is likely to change (for example polled Ajax sourced-data), the drawCallback ensures the visible tables remains current.

    Cheers,

    Colin

  • eoinmcglynneoinmcglynn Posts: 4Questions: 1Answers: 0

    Thank you very much for your very generous help!

This discussion has been closed.