0

I need to export my datatable to pdf, for that I'm using DataTables libraries.

It seems to be running fine here:

However while using the pdfmake.min.js file in lightning component, I'm getting below error. enter image description here

I'm not able to fix this error.

Here is my code: Component:

<aura:component >
<ltng:require scripts="/resource/jquery,
                       /resource/DataTable/DataTables-1.10.18/js/jquery.dataTables.min.js,
                       /resource/DataTable/Buttons-1.5.2/js/dataTables.buttons.min.js,
                       /resource/DataTable/pdfmake-0.1.36/pdfmake.min.js,
                       /resource/DataTable/pdfmake-0.1.36/vfs_fonts.js,
                       /resource/DataTable/Buttons-1.5.2/js/buttons.html5.min.js"
              styles="/resource/DataTable/Buttons-1.5.2/css/buttons.dataTables.min.css,
                      /resource/DataTable/DataTables-1.10.18/css/jquery.dataTables.min.css"
             afterScriptsLoaded="{!c.loadDataToCalendar}"/>

<table id="example" class="display" style="width:100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
    </tbody>
</table>

Controller:

({
loadDataToCalendar :function(component,event,helper){ 

    $(document).ready(function() {
        $('#example').DataTable({

            dom: 'lBfrtip',
    buttons: [

        { extend: 'pdf'
        }
       ],
        });

        } );
        console.log('test');
    }

})

6
  • looks like a locker service limitation you are hitting there.
    – glls
    Jul 18, 2018 at 18:36
  • 1
  • most likelt that the library is not supported with locker service
    – glls
    Jul 18, 2018 at 18:40
  • Based on the able link, I'm using latest version of the library and even reducing the lightning component to 39 version, I'm getting the error Jul 18, 2018 at 18:44
  • If library is not supported then is there any other option to fix the issue? Jul 18, 2018 at 18:45

0

You must log in to answer this question.

Browse other questions tagged .