You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Plugins/buttons/button.download.min.mjs

2 lines
933 B
JavaScript

/*! © SpryMedia Ltd - datatables.net/license */
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;function flattenJson(t,e,o){return o=o||{},e=e||"",$.isPlainObject(t)||Array.isArray(t)?$.each(t,function(t,a){flattenJson(a,""===e?t:e+"["+t.toString()+"]",o)}):o[e]=t,o}DataTable.ext.buttons.download={text:"Download",action:function(t,a,e,o){var n={},a=(a.page.info().serverSide&&$.extend(n,a.ajax.params()),"function"==typeof o.data?o.data(n):"object"==typeof o.data&&$.extend(n,o.data),flattenJson(n)),r=$("<iframe/>").css({border:"none",height:0,width:0}).appendTo(document.body)[0].contentWindow.document,d=(r.open(),r.close(),$("<form/>",r).attr("method",o.type).attr("action",o.url).appendTo(r.body));$.each(a,function(t,a){$("<input/>",r).attr("type","text").attr("name",t.toString()).attr("autocomplete","no").val(a).appendTo(d)}),d.submit()},url:"",type:"POST",data:{}};export default DataTable;