Grouping in DataTables

Grouping in DataTables

oldanioldani Posts: 2Questions: 1Answers: 0

I try to group rows in DataTables but I cannot manage it to work. MY code. is the follwoin g:

$('#ordersTableId').DataTable(
{
data: myData,
columns: [
{"title":"Id Cmd"},
{"title":"Date Cmd"},
{"title":"Email client"},
{"title":"Nom client"},
{"title":"Article"},
{"title":"Quantité"},
{"title":"Prix"}
],
rowGroup: { dataSrc: ['Id Cmd', 'Prix']}
});

Where 'Id Cmd' is the main grouping column name and 'Prix' is the subgrouping column. It turns out that the main grouping works but not the subgrouping. Any idea?

Thanks

Answers

  • colincolin Posts: 14,618Questions: 1Answers: 2,497

    rowGroup.dataSrc isn't the title field, it's

    If your table is using array based data, this should be the column index that contains the data you want to use to group the table. For object-based data sources, it should be the property name in the data source object.

    As you're using array based, you just pass in the number of the column, so something like

    rowGroup: {dataSrc: [0, 6]}
    

    Colin

  • oldanioldani Posts: 2Questions: 1Answers: 0

    Ok great thanks. In the examples it shows string identifiers for the columns not indexes.

Sign In or Register to comment.