This topic contains 5 replies, has 3 voices, and was last updated by Sean Sean 2 years, 1 month ago.

"Export to csv/pdf" not working


  • stzahi
    Participant

    Member Reply #1923

    Hi,

    I’m using Ajax datatable.

    The table works fine but the “tools” section with csv/pdf export is not working.

    What am I missing?

     

    Thank you,

    Tzahi.

    Sean
    Sean
    Keymaster

    Posts: 4527
    Support Staff Reply #1979

    Hi :),

    Thanks for your feedback.

    I would suggest you to double check the datatable initializaiton code and make sure sSwfPath is set properly:

    “sSwfPath”: “../../assets/global/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf”,

    If you need any further assistance please provide us a test link(in a private reply) to your developing site so we can investigate the issue by checking your code.

    Thanks.


    ketav
    Participant

    Posts: 5
    Member Reply #7161

    Hi,

    I’m using Ajax datatable.

    It works fine, But I want to export Data Table to PDF file.

    I’ve include “table-ajax.js” in my project but nothing happens, And I have also tried “table_ajax.html” file from theme.

    “table_ajax.html” File display options for export to various files but it doesn’t work.

     

    Can you please tell me how can i do this?

    • This reply was modified 2 years, 1 month ago by  ketav.
    Sean
    Sean
    Keymaster

    Posts: 4527
    Support Staff Reply #7169

    Hi,

    Could you please provide us a test link to your developing site in a private reply ? We will need to check your code online in order to give you any further advice.

    Thanks.


    ketav
    Participant

    Posts: 5
    Member Reply #7192

    I am using symfony framework and metronic theme.
    I initialize all js in my footer page like this.

    <script>
    jQuery(document).ready(function () {
    Metronic.init(); // init metronic core components
    QuickSidebar.init();
    Index.initDashboardDaterange(); // init index page’s custom scripts
    FormValidation.init();
    TableAjax.init();
    });

    </script>

    This is my table-ajax.js file
    var TableAjax = function () {

    var initPickers = function () {
    //init date pickers
    $(‘.date-picker’).datepicker({
    rtl: Metronic.isRTL(),
    autoclose: true
    });
    }

    var handleRecords = function () {

    var grid = new Datatable();

    grid.init({
    src: $(“#designers”),

    onSuccess: function (grid) {
    // execute some code after table records loaded
    },
    onError: function (grid) {
    // execute some code on network or other general error
    },
    onDataLoad: function(grid) {
    // execute some code on ajax data load
    },
    loadingMessage: ‘Loading…’,
    dataTable: { // here you can define a typical datatable settings from http://datatables.net/usage/options

    // Uncomment below line(“dom” parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
    // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/scripts/datatable.js).
    // So when dropdowns used the scrollable div should be removed.
    “dom”: “<‘row'<‘col-md-8 col-sm-12’pli><‘col-md-4 col-sm-12′<‘table-group-actions pull-right’>>r>t<‘row'<‘col-md-8 col-sm-12’pli><‘col-md-4 col-sm-12’>>”,

    “bStateSave”: true, // save datatable state(pagination, sort, etc) in cookie.
    “tableTools”: {
    “sSwfPath”: baseUrl + “/global/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf”,
    “aButtons”: [{
    “sExtends”: “pdf”,
    “sButtonText”: “PDF”
    }]
    },
    “lengthMenu”: [
    [10, 20, 50, 100, 150, -1],
    [10, 20, 50, 100, 150, “All”] // change per page values here
    ],
    “pageLength”: 20, // default record count per page
    “ajax”: {
    “url”: baseUrl + “getDesignersData”, // ajax source
    },
    “columns”: [{
    “orderable”: true
    }, {
    “orderable”: true
    }, {
    “orderable”: true
    }, {
    “orderable”: true
    }, {
    “orderable”: true
    },{
    “orderable”: true
    },{
    “orderable”: true
    },{
    “orderable”: true
    },{
    “orderable”: false
    }],
    “order”: [
    [1, “asc”]
    ]// set first column as a default sort by asc
    }
    });

    }

    // handle group actionsubmit button click
    grid.getTableWrapper().on(‘click’, ‘.table-group-action-submit’, function (e) {
    e.preventDefault();
    var action = $(“.table-group-action-input”, grid.getTableWrapper());
    if (action.val() != “” && grid.getSelectedRowsCount() > 0) {
    grid.setAjaxParam(“customActionType”, “group_action”);
    grid.setAjaxParam(“customActionName”, action.val());
    grid.setAjaxParam(“id”, grid.getSelectedRows());
    grid.getDataTable().ajax.reload();
    grid.clearAjaxParams();
    } else if (action.val() == “”) {
    Metronic.alert({
    type: ‘danger’,
    icon: ‘warning’,
    message: ‘Please select an action’,
    container: grid.getTableWrapper(),
    place: ‘prepend’
    });
    } else if (grid.getSelectedRowsCount() === 0) {
    Metronic.alert({
    type: ‘danger’,
    icon: ‘warning’,
    message: ‘No record selected’,
    container: grid.getTableWrapper(),
    place: ‘prepend’
    });
    }
    });

    return {

    //main function to initiate the module
    init: function () {

    initPickers();
    handleRecords();
    }

    };

    }();

    Sean
    Sean
    Keymaster

    Posts: 4527
    Support Staff Reply #7199

    Hi,

    Can you deploy your page into your test server and provide us a test link in a private reply ? We will need to check your page online and debug your code. With the above provided code we are not able to fully debug your page.

    Thanks.

You must be logged in to reply to this topic.