Variable page lengths for use with grouping?
Variable page lengths for use with grouping?
Hi,
I've got a requirement that will need a datatable to have grouped rows together. I'm currently using the rowgrouping plugin, but the issue I'm facing right now is that the page lengths are fixed, and groups may span more than one page. I'm thinking of either changing the paging to use server-side processing, and return a variable number of rows, dependent on the number of groupings, ie. instead of returning just 10 rows, return the number of rows that make up 10 groupings. Other thoughts I've had is to see if there's a way to have base datatables have different page lengths for each page, and hence make the rowgrouping plugin work properly. I don't have any code to show just yet, but I thought I would bounce this question off the forum, and see if anybody had any brilliant ideas.
Thanks in advance!
Rob.
I've got a requirement that will need a datatable to have grouped rows together. I'm currently using the rowgrouping plugin, but the issue I'm facing right now is that the page lengths are fixed, and groups may span more than one page. I'm thinking of either changing the paging to use server-side processing, and return a variable number of rows, dependent on the number of groupings, ie. instead of returning just 10 rows, return the number of rows that make up 10 groupings. Other thoughts I've had is to see if there's a way to have base datatables have different page lengths for each page, and hence make the rowgrouping plugin work properly. I don't have any code to show just yet, but I thought I would bounce this question off the forum, and see if anybody had any brilliant ideas.
Thanks in advance!
Rob.
This discussion has been closed.
Replies
It does sound useful though, it will be a little while before I can create anything to do that, as I'm focusing on 1.10 at the moment, but it sounds like a good idea for a blog post in future.
Allan
One question though, if I'm returning arbitrary number of 'detail' rows - possibly greater than the iDisplayLength parameter passed in the request, will this cause issues with datatables rendering all of the rows that are returned?
Thanks.
Rob.
Allan
I took another tack at this issue. Using your "Hidden Rows Example" here: http://datatables.net/release-datatables/examples/api/row_details.html, I decided to experiment with that. I set up a summary table, that datatables is bound to, and I then had another table that is hidden, that has all of the detail rows in it. I hacked some jQuery code together to pull the rows of data from the detail table and insert it as the 'expanded' rows when the '+' button is clicked. This *almost* gets me what I want. One of the issues is that the detail row columns don't line up with the summary row columns, primarily because it seems I need to wrap the detail rows in anther table tag. Now I think I have two ways of fixing this:
1) Figure out how to insert the detail rows as extra rows underneath the expanded summary row, or
2) Grab the summary table header row, and insert the width attributes into the columns in the details row table.
I've put a working example up on jsfiddle here: http://jsfiddle.net/hftb/jjMQD/9/
If you could have a look, and maybe provide some suggestions, it would be greatly appreciated!
Thanks!
Rob.