如何在Datatable中确认文件导出后重新加载页面?

时间:2017-08-09 08:30:10

标签: javascript jquery datatable

我正在效仿这个例子:

https://datatables.net/extensions/buttons/examples/initialisation/export

我想如果我确认文件导出,页面将重新加载。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您可以自定义按钮的操作。试试这个:

$(document).ready(function() {

  $('#example').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        {//Start the creation of the button
          extend: "csv",//It's a button that export the table dtat into a CSV file
          text: "export and relode",//The text of the button
          action: function(e, dt, button, config) {
                //The action of the button
                $.fn.dataTable.ext.buttons.csvHtml5.action.call(this, e, dt, button, config);//Export the data
                window.location.reload(false);//Relode the page
                    }
        }
    ]
  });

}); 

这是一个有效的 Fiddle