Keeping an entire rowSource group together
Keeping an entire rowSource group together
Is it possible to programmatically keep all rows within a rowSource grouping together within the same page (thus possibly overriding the pre-set page length)?
For example, if I have a dataset to display using DataTables that has a total of 100 records, and I set my default page length to 10. Assume that one of the groupings within that 100 records has 25 records, while other groupings have 4 or 5 or 10 records.
Is it possible to visually keep all 25 records of the large rowSource grouping together on a single display page? The issue becomes that if I want to use the startRender or end Render function within rowSource, that if a grouping of say 25 records happens to fall so that some portion of the records is on one page, and the remainder is on the next page, then the startRender (or endRender) will execute twice, once for each subset of the records on its page. The end result is that any calculations displayed as the result of the renderer being executed once for each subset, is that the displayed calculations aren't correct for the entire grouping, but only for each subset of the grouping.
I hope this makes sense. I'll try to build a fiddle later today that illustrates what I'm asking.
Answers
After a bit of thought, it comes to mind that if I can determine the largest number of rows in any rowSource grouping within my dataset, that I can then dynamically change the pageLength to that number plus 1 or 2 (enough to allow for all the rows in a grouping plus the header row for the grouping.
And that a starting point for doing this would be to set pageLength to something like the total number of records in the dataset, then as each rowSource grouping is rendered, if the number of rows for that grouping is larger than the previously known number of rows, save that new value, etc. etc. Then at the end of the rendering for the whole DataTables object, set the pageLength for the DataTables object to that value + 2.
Hi,
There was a question on exactly this topic just a couple of days ago here. As I mention there, I think filtering is probably a better way to do this rather than to use RowGroup.
Allan