以Datatable PDF和Excel导出图像视图

时间:2019-01-14 09:12:23

标签: php jquery datatables laravel-blade

我正在使用Laravel Blade文件。我想将表格导出为PDF,它似乎可以正常工作。但是,显示图像时出现问题。它仅显示图像路径,而不显示导出后的图像。

exportOptions: {
    stripHtml: false,

已添加但无法正常工作

$(document).ready(function() {
  var buttonCommon = {
     extend : 'pdfHtml5',
    exportOptions: {
              stripHtml: false,
              columns: 'th:not(:last-child)',

     exportOptions: {
              stripHtml: false,
              //columns: 'th:not(:nth-child(2))',
        format: {
            body: function ( data, row, column, node ) {
                // Strip $ from salary column to make it numeric
                return column === 4 ?
                    data.replace( /[$,]/g, '' ) :
                    data;
            }
        }
     }
    }
};
  //$.noConflict();
   $('.datatable').DataTable({
       processing: true,
       serverSide: true,
       //"oSearch": { "bSmart": false, "bRegex": true },
       ajax: '{{ route('customers.getdata') }}',
       columns: [
           {data: 'id', name: 'id'},
           {data: 'profilepic', name: 'profilepic',render: function( data, type, full, meta ) {
                   if(data==0) { return "<img src=\"/customers/default.png"  + "\" height=\"50\"/>"; } else { return "<img src=\"/customers/" + data + "\" height=\"50\"/>"; }
                }},
           {data: 'name', name: 'name'},
           {data: 'email', name: 'email'},
           {data: 'phone', name: 'phone'},
           {data: 'address', name: 'address'},
           {data: 'created_by', name: 'created_by'},
           {data: 'status', name: 'status',render: function( data, type, full, meta ) {
                    if(data==1) { return "Active"; } else { return "Inactive"; }
                }},
        {data: 'action', name: 'action', orderable: false, searchable: false}
       ],
       dom: 'Bfrtip',
       buttons: [
        $.extend( true, {}, buttonCommon, {
            extend: 'copyHtml5',

        } ),
        $.extend( true, {}, buttonCommon, {
            extend: 'excelHtml5',

        } ),
        $.extend( true, {}, buttonCommon, {
            extend: 'pdfHtml5',

        } )
    ]

   });
});

我需要一个图像视图而不是一个图像路径。

0 个答案:

没有答案