Group rows with matching column X

Group rows with matching column X

thomassmartthomassmart Posts: 2Questions: 0Answers: 0
edited May 2011 in General
Hello
First i would like to say "what an excellent product"! I have been playing around with it and it is exactly what I will be needing for a project I have coming up later this year. Currently I am trying to find solutions to a few issues and have succeeded in most but this seems to be one of the more trickier ones. Or i am just tired and overlooking things.

I have a data set like this (very simplified):
ID, ORDERID, CLIENT, STATUS
1, 1, Thomas, Opened
2, 2, Fred, Opened
3, 1, Thomas, Paid
4, 2, Fred, Paid
5, 1, Thomas, Closed

As you can see "orderid" is repeated a couple of times however in the table i only want to show the last result for an orderid. and add the other entries for that order id below the main one. The user can then click a + to open the subrows.

I have managed to do this quite nicely and the table looks something like this:
ID ORDERID CLIENT STATUS
+ 1 1 Thomas Closed
+ 4 2 Fred Paid

When the user clicks the "+" it looks like this:
ID ORDERID CLIENT STATUS
- 1 1 Thomas Closed
3 1 Thomas Paid
5 1 Thomas Opened
+ 4 2 Fred Paid

This all works beautifully on first load. But then the problems:

1. I update the "subrows" through the row callback adding a class "subrow" that has the style setting "display:none". Datatables does not seem to like this and when i filter/order the table it seems to have removed these rows and does not show them any more when i click the +

2. the correct grouping for the subrows is that they should be descendingly ordered by ID, the latest ID should be displayed as the mainrow and the remaining rows are subrows. When i order the columns in datatables it messes with this ordering. If i force datatables to order by the orderID then ordering by the other columns does not do much as it orders by orderID first.

The correct displaying would be:
filter or order results as the user likes
move all the rows with the same ORDERID column together, ordered descendingly by the ID column within that group.

if needed again:
attach the special class name to the subrows for colouring
attach the special class name to the subrows to connect them to the mainrow
attach the click function to the first column of the mainrow

Can this be done with the built in functionality, api or plugin?
(with an acceptable amount of processing power required)

Thank you
Thomas

Replies

This discussion has been closed.