Is there any way to export whole data?

Is there any way to export whole data?

luieyluiey Posts: 1Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I have 12 column of data query from webmethod. But on display I will only show 4 columns. The rest of the column should be written when user click Export button.

HTML:

<style>
    .exportcolumn {
        display: none;
    }
</style>
<table id="tbldata" class="table table-bordered table-striped" style="width: 100%">
    <thead>
        <tr>
            <th>ID</th>
            <th>LOT</th>
            <th>NAME</th>
            <th class="exportcolumn">CARDBOARD</th>
            <th class="exportcolumn">PAPER</th>
            <th class="exportcolumn">PLASTIC</th>
            <th class="exportcolumn">METAL</th>
            <th class="exportcolumn">ALUMINIUM</th>
            <th class="exportcolumn">DRINK CARTON</th>
            <th class="exportcolumn">POLYSTYRENE</th>
            <th class="exportcolumn">TEXTILE</th>
            <th class="exportcolumn">FOOD WASTE</th>
            <th>WEIGHT</th>
            <th>TOTAL</th>
            <th>LINK</th>
        </tr>
    </thead>
</table>

The class exportcolumn will be write to excel as report. The issue is when I click search button to query new record, the column will be flick and visible before it hide after load complete.

On the ajax webmethod return, I have:

"buttons": [{
    extend: 'excelHtml5',
    text: 'Export',
    className: 'btn btn-primary',
    footer: true,
    title: 'Summary Reporting for ' + new Date($('#txtDateFrom').val()).slashDate() + ' - ' + new Date($('#txtDateTo').val()).slashDate(),
    filename: function () {
        return 'TenantsReporting ' + new Date($('#txtDateFrom').val()).yyyymmdd() + '-' + new Date($('#txtDateTo').val()).yyyymmdd();
    },
    exportOptions: {
        columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
    }
}],

Is there a way for plugins in this button to get the data: jQuery.parseJSON(data.d) so it can export whole complete data so that I can prevent the unneccessary bind new jquery with visible flick of hidden column?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I'm not too clear what you mean, sorry. Are you saying that you need to make the hidden column visible for it to be exported? That shouldn't be the case, as this example demonstrates that hidden columns are still exported by default.

    Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

Sign In or Register to comment.