I am stack how i can export grouped row with its subtotals

I am stack how i can export grouped row with its subtotals

nakuresnakures Posts: 2Questions: 1Answers: 0

I can export table with groupded rows but not its corresponding subtoatals, Pls help if any idea is appreciated: I am using this

$('.example').DataTable({
dom: 'Bfrtip',
lengthChange: false,

        buttons: [{
            extend:'excel',
            text: 'Export to excel',

                exportOptions: {
    //n is the index of the column you want to group by.
    //for example if you want to group by the first col, you would use 0 for n
    grouped_array_index: [ 2 ], //note the brackets, i think this is so you can group by multiple columns.

columns: ':visible'
}

                      },{
            extend:'pdf',
                    text: 'Export to pdf',
          title: 'Bills of quantity as on',
          footer: true,
          stripHtml: false,
          decodeEntities: true,
          orientation: 'landscape',
          filename: 'boq',
          pageSize: 'LEGAL',
          paging:true,
                exportOptions: {
    //n is the index of the column you want to group by.
    //for example if you want to group by the first col, you would use 0 for n
    grouped_array_index: [ 2 ] ,//note the brackets, i think this is so you can group by multiple columns.
    columns: ':visible',
     sumGrouping: true,

    modifier: {
                page: 'current'
            }
  }                        

                      },

{
extend:'print',

                exportOptions: {
    //n is the index of the column you want to group by.
    //for example if you want to group by the first col, you would use 0 for n
    grouped_array_index: [2],//note the brackets, i think this is so you can group by multiple columns.
    columns: ':visible'
  }                        

                      }                          


        ],

        paging:false,
        searching:false,
            "bInfo" : false, 
            destroy: true,
            //drawCallback: addSubtotals,

});

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    This thread discusses how to export the RowGroup header. Hopefully that'll help.

    Colin

  • nakuresnakures Posts: 2Questions: 1Answers: 0

    I am able to export table with RowGroup but not its subtotal at right side of thet grouped headers
    see the code

    ('.example').DataTable({
        rowGroup: {
            dataSrc: 'group'
        },
          dom: 'Bfrtip',
             lengthChange: false,
             
     
                buttons: [{
                    extend:'excel',
                    text: 'Export to excel',
                            
                        exportOptions: {
            //n is the index of the column you want to group by.
            //for example if you want to group by the first col, you would use 0 for n
            grouped_array_index: [ 2 ], //note the brackets, i think this is so you can group by multiple columns.
    columns: ':visible'     
          }                        
          
                           
                              },{
                    extend:'pdf',
                            text: 'Export to pdf',
                  title: 'Bills of quantity as on',
                  footer: true,
                  stripHtml: false,
                  decodeEntities: true,
                  orientation: 'landscape',
                  filename: 'boq',
                  pageSize: 'LEGAL',
                  paging:true,
                        exportOptions: {
            //n is the index of the column you want to group by.
            //for example if you want to group by the first col, you would use 0 for n
            grouped_array_index: [ 2 ] ,//note the brackets, i think this is so you can group by multiple columns.
            columns: ':visible',
             sumGrouping: true,
            
            modifier: {
                        page: 'current'
                    }
          }                        
                           
                              },
    {
                    extend:'print',
                            
                        exportOptions: {
            //n is the index of the column you want to group by.
            //for example if you want to group by the first col, you would use 0 for n
            grouped_array_index: [2],//note the brackets, i think this is so you can group by multiple columns.
            columns: ':visible'
          }                        
                           
                              }                          
                              
               
                ],
                
                paging:false,
                searching:false,
                    "bInfo" : false, 
                    destroy: true,
                    //drawCallback: addSubtotals,
    
       });       
                
                
    
    
    
  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.