Skip Navigation

[Resolved] Our 'Export CSV' is no longer working

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by Minesh 2 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#2361237

Hi Luo,

Thank you for your help.

Was wondering if you could possibly answer another question.
The View that we have set-up: hidden link

Our 'Export CSV' is no longer working.

Here is the code: Export to CSV (Need to Print this Page? --> Right click on the page then choose "Print" in the options menu)

Is there a targeted reason why this would stop working?

Here is the full Loop:

[wpv-layout-start]
[wpv-items-found]

Export to CSV (Need to Print this Page? --> Right click on the page then choose "Print" in the options menu)

<div id="exportData" class="table-responsive">
<table width="100%" class="table table-bordered">
<thead>
<tr>
<th>Vendor Name</th>
<th>Business Name</th>
<th>Vendor Email</th>
<th>Vendor Type</th>
<th>Payment Status</th>
</tr>

<tbody>
<!-- wpv-loop-start -->
<wpv-loop>
<tr>
<td class="ven_name">[types field='your-name'][/types]</td>
<td class="ven_name">[wpv-post-title]</td>
<td class="ven_email">[types field='personal-email' output='raw'][/types]</td>
<td class="ven_type">[wpv-post-taxonomy type="vendor-types" format="name"]</td>
<td class="ven_name">[types field='show-date-payment-accepted-on'][/types]</td>
</tr>
</wpv-loop>
<!-- wpv-loop-end -->
</tbody>
</table>
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

Thank you!
Tracy

#2361605

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Toolset do not offer any feature to export the view result as CSV you must be using some custom PHP or JS code that should be broken.

I'm not sure yet how you integrated the export csv functionality and using what code. Do you see any JS error on your browser's console?

#2361627

Hi Minesh,

I do see an error. Just not sure how to fix it. I've attached a screen shoot.

jQuery(document).ready(function ($) {

function exportTableToCSV($table, filename) {

var $rows = $table.find('tr');

var csvData = "";

for(var i=0;i<$rows.length;i++){
var $cells = $($rows[i]).children('th,td'); //header or content cells

for(var y=0;y<$cells.length;y++){
if(y>0){
csvData += ",";
}
var txt = ($($cells[y]).text()).toString().trim();
if(txt.indexOf(',')>=0 || txt.indexOf('"')>=0 || txt.indexOf('n')>=0){
txt = """ + txt.replace(/"/g, """") + """;
}
csvData += txt;
}
csvData += 'n';
}

// Data URI
csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csvData);

$(this)
.attr({
'download': filename,
'href': csvData,
'target': '_blank'
});
}

// This must be a hyperlink
$(".exportCsv").on('click', function (event) {
// CSV
exportTableToCSV.apply(this, [$('#exportData>table'), 'Export-List.csv']);

// IF CSV, don't do event.preventDefault() or return false
// We actually need this to be a typical hyperlink
});
});

#2361629

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I do not see any screenshot with your previous reply. Could you please upload the screenshot to any file sharing service and send me the link to see it.

#2361719
Screen Shot 2022-05-12 at 8.39.14 AM.jpg

Sure, here is the link. hidden link

#2362265

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Based on the screenshot you shared there is no evidence that this is Toolset problem or as shared before Toolset do not offer any view result export feature and hence you coded it using custom JS code.

As per our support policy we do not offer support for such custom edits but still I would like to give a try once and for that I will require admin access details and problem URL where you added your view.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2364389

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If I try to access the page on staging link: hidden link

It says there is no page there. Can you please tell me on what page I should check the issue on staging site?

#2364639

hidden link

The page is called Vendor Payment Center. And it was on Private Mode, I've enabled It on the test site.

Thanks,
Tracy

#2364941

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now: hidden link

The issue was at the following line of the code with the custom JS code you added:

txt = """ + txt.replace(/"/g, """") + """;

The custom JS code you added to your view's JS section, I've changed the following line of the code from:

txt = """ + txt.replace(/"/g, """") + """;

To:

txt = '"' + txt.replace(/"/g, '""') + '"';

The was a pure custom programming request and for further assistance on that I suggest you should contact our certified partners as to support such custom edits is beyond the scope of our support policy:
=> https://toolset.com/contractors/