DataTables - RowGroup extension question about DateTime
DataTables - RowGroup extension question about DateTime
![Arniox](https://secure.gravatar.com/avatar/24cb8a1b2d2d53c650ed57c877555d9c/?default=https%3A%2F%2Fvanillicon.com%2F24cb8a1b2d2d53c650ed57c877555d9c_200.png&rating=g&size=120)
At the moment, I managed to get the RowGroup "plugin" working pretty easily and wanted to group the DateTime section of my table by weekly, or yearly sections. However, it seems to auto group by unique data entry so every single item has been made it's own group out of 10,000+ rows
How do I create RowGroups on DateTime rows that encompass a specific time range?
This is what I currently have and what it looks like (mostly redacted)
$(document).ready(function () {
var table = $('#currentJobsTable').DataTable({
order: [[5, 'desc']],
rowGroup: {
dataSrc: 5
}
});
});
This question has an accepted answers - jump to answer
Answers
I have tried this but you might be able to use
rowGroup.dataSrc
as a function. See the comments at the end of the documentation.Kevin
Yep, as Kevin said, here's an example of that.
Colin
Same problem here, i am seeing duplicates i am grouping by
Tried pre sorting , changing format, same results.
@imaginet Are you sorting by the
date_from
column?If not that might be why you are seeing duplicates. If this doesn't help then please provide a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
you have the same bug here
http://live.datatables.net/ziweyuyu/54/
It is a similar usecase
this is the change i made, i grouped by Year
I'm not sure if there are any duplicate years in the data for the test case you linked to. I made the change, `return row[4].substr(0, 4);, to that test case and it seems to be working:
http://live.datatables.net/zeyesufi/1/edit
There are no duplicate years.
In your code snippet you have
order: [[3, 'asc']],
which is not the date column for this test case.Kevin
Thank you so much, you have put me on the right track.
the issue was as following:
This code works as expected
Thanks,
keep up the amazing work