problem in exporting in CSV file

problem in exporting in CSV file

Neeraj kumarNeeraj kumar Posts: 8Questions: 5Answers: 0

Earlier Issue has been fixed but the problem i facing right now is that when i am trying to Export CSV file i am getting the data only on the display which has been rendered rather than Getting the complete data.
Total Data Is 1820 But 1 Page Renders 10 And When I Downlaod The Csv It Gives Only 10 Records What I Want Is Show Is 1820 Records
P.F.A of the Screen Shot of the following issue

This question has an accepted answers - jump to answer

Answers

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28
    Answer ✓

    Hi Neeraj kumar,
    could you provide a link to a working example, as required by the forum rules.

    This shouldn't happen, because in the buttons.exportData() it says that the default value for the row-selector and column-selector is ALL.

  • Neeraj kumarNeeraj kumar Posts: 8Questions: 5Answers: 0

    Hi F12Magic,

    this my code

    $(document).ready(function() { handleChange(); }); function handleChange() { var token = document.getElementsByName("token")[0].value; var dtRender= $('#loginHistoryDataTable').DataTable({ dom : 'BTftlpi', buttons : [ { extend : 'copyHtml5', exportOptions : { columns : [ ':visible' ] } }, { extend : 'csvHtml5', title : 'Login History', exportOptions : { columns : [ ':visible' ] } }, { extend : 'pdfHtml5', title : 'Login History', exportOptions : { columns : [ ':visible' ] } }, { extend : 'print', title : 'Login History', exportOptions : { columns : [ 0, 1, 2, 3, 4, 5, 6 ] } },{ extend : 'colvis', // collectionLayout: 'fixed two-column', columns : [ 1, 2, 3, 4, 5, 6,] } ], "ajax" : { type : "POST", url : "loginHistoryAction", data : { emailId : document.getElementById("merchant").value, token:token, "struts.token.name": "token", } }, "processing": false , "serverSide": true, "paginationType": "full_numbers", "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], "order" : [ [ 1, "desc" ] ], "columns" : [ { "data" : "businessName", }, { "data" : "ip", "width" : '14%' }, { "data" : "browser", "width" : '13%' }, { "data" : "os", "width" : '10%' },{ "data" : "status", }, { "data" : "timeStump", }, { "data" : "failureReason" } ] }); popup=dtRender; dtRender.on( 'xhr', function () { var data = dtRender.ajax.json(); dataSet=JSON.stringify(data); } ); }
  • allanallan Posts: 61,867Questions: 1Answers: 10,136 Site admin

    The problem is that the data for export is obtained using $().html() and then stripping out the HTML. Since the labels for the option list are text nodes, they are retained. You need to use a custom formatter to get only the label for the selected option.

    The nightly version of Buttons passes the cell node into the formatting function, and you can then use jQuery to get the correct label and simply return that.

    Allan

This discussion has been closed.