table with row grouping and child rows
table with row grouping and child rows
Hello, I'm trying to find a way to show data in a table with rows grouped by certain common data and, for each group, show subrows with other data.
For example:
The table contain a list of credit cards, with number, name of owner etc.
Exploding each card, I would see the transactions of that card, with data of transaction, amount, type etc.
Is there a way to do this kind of grouping, considering that I recover data from a table view on a database that contains, for each row, data as follows:
ID | CC_NUMBER | OWNER_NAME | TRANSACT_ID | TRANSACT_DATA | TRANSACT_AMOUNT | TRANSACT_TYPE|
I've seen this similar question
https://datatables.net/forums/discussion/68051/how-to-group-child-rows-in-datatables
but answers are not what I'm looking for. Grouping seems ok but there are duplicates and group rows has only one field(city name); it also seems that collapsing / expanding is not a feature of grouping plugin
Answers
RowGroup supports multiple levels of grouping which is sounds like what you want?
As you say though, it doesn't not have a collapse function yet - that is something I plan to add after the release of DataTables 2.
Allan
@allan thanks for your answer
as seen in the example given by you, each grouping row has only one value (i.e. Office for the top level, Position for second level). Is there a way to have both on the same level of grouping?
Thanks
That's purely due to the data in the table. If you go to the second page of the table, you'll see multiple rows in some of the groups (because in those cases, there are multiple people in an office with a the same title):
Allan
There are some solutions presented on the forum for collapsed groups. See this example from this thread.
If you are asking about combining two columns that will be grouped then try using
rowGroup.dataSrc
as a function. See the comments at the end of the page. You will need to sort the table by both columns for the grouping to work. See this thread for a running example.Kevin