Data table append is not working to rendar the data table buttons at particular location

Data table append is not working to rendar the data table buttons at particular location

ravi_2504ravi_2504 Posts: 4Questions: 1Answers: 0

Hi All,

I am working on DataTable Buttons export functionality,Buttons are working fine.I want to place that button in the page according my requirement.So I used this code snippet from DataTables

var table = $('#example').DataTable();

    new $.fn.dataTable.Buttons( table, {
        buttons: [
            'csvHtml5'
        ]
    } );

     table.buttons().container()
        .appendTo( $(' .spanclassb', table.table().container() ) ); 

I am I missing something here? Please help me to understand.
Please find my live test case
http://live.datatables.net/tetiqoye/2/edit

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    this worked, it lets DataTable create the button normally that moves it with detach then append.

      var table = $('#example').DataTable({dom: 'frtipB',
                buttons: [
                    'csvHtml5'
                ]
            });
            var detached =  $(".dt-buttons").detach();
    $(".spanclassb").append(detached);
    
    
  • bindridbindrid Posts: 730Questions: 0Answers: 119

    but if you want the buttons at the bottom you can just do

    var table = $('#example').DataTable({dom: 'frtipB',
                buttons: [
                    'csvHtml5'
                ]
            });
    
    
  • ravi_2504ravi_2504 Posts: 4Questions: 1Answers: 0

    Thanks for the answer bindrid,it worked. I need to add button where ever I want so I created span for that.I need custom styles for the buttons like color etc..

  • ravi_2504ravi_2504 Posts: 4Questions: 1Answers: 0

    The above example working perfect in my local machine.But the same example is not working in my office work space. I have all necessary js/css (versions might be different and browser is IE11) but buttons are not displaying.What could be the possible problem?
    As it is my office work space I could not give test url.

  • ravi_2504ravi_2504 Posts: 4Questions: 1Answers: 0

    how to customise the export(save) location of the file for export buttons.For example when I click on csv button I want to save the csv file to particular drive location.

This discussion has been closed.