Dynamic idisplaylength row group items

Dynamic idisplaylength row group items

KarlDimeKarlDime Posts: 16Questions: 3Answers: 0
edited December 2020 in Free community support

EDIT:
My table shows 10 entries per page, but sometimes a group has more than 10 items,
Splitting the group between pages.

How can i have a dynamic iDisplayLength to: Show N number of groups, instead N number of items.

I'm using this code to enable row grouping http://live.datatables.net/cecosoru/1/edit

How can i show N groups, instead of N items?

Aka change the "iDisplayLength": to reflect the number of groups, instead of the number of items that are in the groups.

Any help would be greatly apreciated, thank you.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,252Questions: 26Answers: 4,761
    edited December 2020

    iDisplayLength is the pageLength option. Are you wanting to do something with the length change element?

    Please provide more details of where you want to display the number of groups.

    Kevin

  • KarlDimeKarlDime Posts: 16Questions: 3Answers: 0

    Hello, sorry for not being clear enough, my problem resides in the items displayed at once, sometimes a group may be split into more than one page etc.
    How can i make this process dynamic? show N groups with variable items for each one.

  • KarlDimeKarlDime Posts: 16Questions: 3Answers: 0
  • kthorngrenkthorngren Posts: 20,252Questions: 26Answers: 4,761
    edited December 2020

    Are you saying that you want the page length to change based on the size of the group?

    Or are you saying that instead of London (1), on the first page, you want to display London (12) since there are 12 rows with London?

    Kevin

  • KarlDimeKarlDime Posts: 16Questions: 3Answers: 0

    Page length change based on the size of groups, to be especific: show 5 complete groups on every page

  • kthorngrenkthorngren Posts: 20,252Questions: 26Answers: 4,761
    Answer ✓

    You won't be able to get the results you want with how Datatables performs paging. I put together a simple example that shows one group per "page". My solution uses pageLength of -1 and removes paging. It builds a select list similar to this Select search example.

    The key is this example builds an API that can be called which works with a search plugin to display the selected RowGroup.
    http://live.datatables.net/gafuwovu/1/edit

    The example can be adapted to display multiple groups. Also you can create a different input to handle paging through the groups as you wish. Feel free to build up the example to work the way you want if you want further help.

    Kevin

  • KarlDimeKarlDime Posts: 16Questions: 3Answers: 0

    Thank you for the code, have a
    good one

This discussion has been closed.