dataTables export button display in custom position?

后端 未结 2 1316
情深已故
情深已故 2020-12-16 06:56

I want to show my dataTable export button in custom div . how can I Do this ?

my Current code

this is default code and buttons show seperatly on top of my

2条回答
  •  失恋的感觉
    2020-12-16 07:46

    It is quite a headache to clone the button events and destroy the elements. Why not just hide the buttons panel and click the buttons programmatically? Can be automized this way :

    
    

    Add a initComplete handler to the dataTables initialization options :

    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(); 
      })
    } 
    

    updated fiddle -> https://jsfiddle.net/qt9p2fwt/17/

提交回复
热议问题