Reputation: 175
I've got a table that I want to be able to group by different columns, based on User Input. I've started using the RowGroup plugin since this is pretty much exactly what I was looking for, and also found a way to expand/collapse the groupings.
My issue is that for one of the specific groupings, the grouping mechanic doesn't actually function properly, and creates multiple groups when I believe it shouldn't be doing so. The data comes in from the server, so I'm able to apply a .trim() function on the strings in the selected column for grouping.
Below is a link to a copy of my table with the DataTables code that I have implemented, with the only difference being that my version of DataTables is actually 1.10.16, whereas the version used here is 1.10.21-dev - Since I copied in the rest of the code and it worked the same way, I opted to leave the version as it was.
http://live.datatables.net/layudizi/1/edit
If you swap between dataSrc: 4 (problem) and dataSrc: 0 (working properly) you'll see how when grouping by Column 4 (Customer) it will create multiple groupings with the same Customer Number, but when you group by Column 0 (Item Code) there is one group per code. Have I missed something?
Upvotes: 2
Views: 4495
Reputation: 5310
You see that effect because of your ordering. If you change the order to column 4 as well, you should see the same result as 0. The row grouping is dictated by the adjacent rows, if you are not ordered by the same column then the result is segmented.
dataSrc: 4,
"order" : [[4,'asc']]
Upvotes: 3