When I give print it doesn't print as a group

When I give print it doesn't print as a group

abdulbarictabdulbarict Posts: 1Questions: 1Answers: 0

When I give print it doesn't print as a group. How to do this. please help me to do this.
code is bellow.

var groupColumn = 0;
    product_sell_grouped_report = $('table#product_sell_grouped_report_table').DataTable({
        processing: true,
        serverSide: true,
        order: [[groupColumn, 'asc']],
        // aaSorting: [[groupColumn, 'asc']],
        ajax: {
            url: '/reports/product-sell-grouped-report',
            data: function(d) {
                var start = '';
                var end = '';
                var start_time = $('#product_sr_start_time').val();
                var end_time = $('#product_sr_end_time').val();
                if ($('#product_sr_date_filter').val()) {
                    start = $('input#product_sr_date_filter')
                        .data('daterangepicker')
                        .startDate.format('YYYY-MM-DD');
                    end = $('input#product_sr_date_filter')
                        .data('daterangepicker')
                        .endDate.format('YYYY-MM-DD');

                    start = moment(start + " " + start_time, "YYYY-MM-DD" + " " + moment_time_format).format('YYYY-MM-DD HH:mm');
                    end = moment(end + " " + end_time, "YYYY-MM-DD" + " " + moment_time_format).format('YYYY-MM-DD HH:mm');
                }
                d.start_date = start;
                d.end_date = end;

                d.variation_id = $('#variation_id').val();
                d.customer_id = $('select#customer_id').val();
                d.location_id = $('select#location_id').val();
                d.category_id = $('select#psr_filter_category_id').val();
                d.brand_id = $('select#psr_filter_brand_id').val();
                d.customer_group_id = $('#psr_customer_group_id').val();
            },
        },
        columnDefs: [{ visible: false, targets: groupColumn }],
        columns: [
            { data: 'category_name', name: 'category_name', visible: false },
            { data: 'product_name', name: 'p.name' ,orderable:false},
            { data: 'sub_sku', name: 'v.sub_sku' ,orderable:false},
            // { data: 'transaction_date', name: 't.transaction_date' },
            { data: 'current_stock', name: 'current_stock', searchable: false, orderable: false },
            { data: 'total_qty_sold', name: 'total_qty_sold', searchable: false ,orderable:false},
            { data: 'subtotal', name: 'subtotal', searchable: false ,orderable:false},
        ],
        fnDrawCallback: function(oSettings) {
            $('#footer_grouped_subtotal').text(
                sum_table_col($('#product_sell_grouped_report_table'), 'row_subtotal')
            );
            $('#footer_total_grouped_sold').html(
                __sum_stock($('#product_sell_grouped_report_table'), 'sell_qty')
            );
            __currency_convert_recursively($('#product_sell_grouped_report_table'));
            categoryGrouped(oSettings);
        },
    });
    function categoryGrouped(settings) {
        var api = settings.oInstance.api();
        var rows = api.rows({ page: 'current' }).nodes();
        var last = null;
    
        api.columns(groupColumn, { page: "current" }).every(function () {
            this.data().each(function (group, i) {
     
            if (last !== group) {
                $(rows).eq(i).before(
                    '<tr class="group"><td colspan="5">' + group + '</td></tr>'
                );
    
                last = group;
            
            
            }
            });
        });
    }

Answers

  • kthorngrenkthorngren Posts: 20,991Questions: 26Answers: 4,887

    This is an old thread but the answer still applies. It will require using the customize option of the print export to modify the output.

    Kevin

Sign In or Register to comment.