2017-12-06 6 views
0

jquery datatable와 함께 작업하고 있습니다. lengthMenu와 내보내기 단추도 표시하려고합니다. lengthMenu는 정상적으로 작동하지만 lengthMenu 내보내기 버튼을 추가하면 내보내기 버튼이 작동하지 않습니다. 이 문제는 누구나이 문제를 해결하는 데 도움이 될 수 있습니다.Jquery Datatable 내보내기 단추가 lengthMenu와 함께 작동하지 않습니다.

  $(document).ready(function() { 
    $('#DeviceData').DataTable({ 
     dom: 'Bfrtip', 
     buttons: [ 
      'copy', 'csv', 'excel', 'pdf', 'print' 
     ], 
     "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], 
     sDom: "<'call-header'<'dthead'>l<'ttools'T><'filterinput'f>r><'dttoolbar'><'dataTables_scroll'<'dataTables_scrollBody't>><'call-footer'<'row-fluid'<'span6'i><'span6'p>>>", 

     initComplete: function() { 
      var $buttons = $('.dt-buttons').hide(); 
      $('#exportLink').on('change', function() { 
       var btnClass = $(this).find(":selected")[0].id 
        ? '.buttons-' + $(this).find(":selected")[0].id 
        : null; 
       if (btnClass) $buttons.find(btnClass).click(); 
      }) 
     } 
    }); 
}); 

답변

0

이 질문은 이미 다음 링크를 확인하기 전에 질문합니다.

https://stackoverflow.com/questions/17564447/jquery-datatable-excel-export-is-not-working 

https://stackoverflow.com/questions/19294974/export-to-csv-excel-feature-does-not-work-in-datatable