Can't change "Title" of a Excel, PDF exported file.

Can't change "Title" of a Excel, PDF exported file.

joaooanzolimjoaooanzolim Posts: 5Questions: 2Answers: 0
edited January 4 in Free community support

I'm trying to export a excel, PDF, SVG file of my table and it's working fine, but I need to change the name of file to the value selected on SearchBuilder using searchBuilder.getDetails().criteria; The code I built returns the value if I try to output in Console, but doesnt work in the file name... Follow my code:

PS: The code I'm talking about is the last lines of . I think its not working because its not inside in the function of table:

$(document).ready(function() {
var table = $('#datatable').DataTable...

Thanks in advance!

This question has an accepted answers - jump to answer


  • allanallan Posts: 58,324Questions: 1Answers: 9,334 Site admin
    Answer ✓

    If I'm reading the code correctly, it is just setting the valorExportar variable when the table is loaded. Also valorExportar is undefined when it is used for the button.

    You are better to use a function for something like this:

      function valorExportar() {
        var d = $('#datatable').DataTable().searchBuilder.getDetails().criteria;
        for(var i = 0; i < d.length; i++){
          if (d[i]['data'] == "Age"){
            var result = d[i]['data'];
            return result;
        return '';

    That way it will be executed when it is needed.

    I don't see a way to save my changes on that pen, but that's basically it.


  • joaooanzolimjoaooanzolim Posts: 5Questions: 2Answers: 0

    Thank you very much, Allan! It worked well.

Sign In or Register to comment.