From 00ca30a2056f664299014313f2a746e277dd5ed2 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Tue, 22 Mar 2022 15:12:11 +0000 Subject: [PATCH] WIP: fix bootstrap table export options --- .../views/partials/bootstrap-table.blade.php | 113 ++++++++++-------- 1 file changed, 60 insertions(+), 53 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 2b2f820fb5..49b4bffa34 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -30,62 +30,69 @@ return false; } - $('.snipe-table').bootstrapTable('destroy').bootstrapTable({ - classes: 'table table-responsive table-no-bordered', - ajaxOptions: { - headers: { - 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') - } - }, - stickyHeader: true, - stickyHeaderOffsetY: stickyHeaderOffsetY + 'px', - undefinedText: '', - iconsPrefix: 'fa', - cookie: true, - cookieExpire: '2y', - mobileResponsive: true, - maintainSelected: true, - trimOnSearch: false, - showSearchClearButton: true, - paginationFirstText: "{{ trans('general.first') }}", - paginationLastText: "{{ trans('general.last') }}", - paginationPreText: "{{ trans('general.previous') }}", - paginationNextText: "{{ trans('general.next') }}", - pageList: ['10','20', '30','50','100','150','200'{!! ((config('app.max_results') > 200) ? ",'500'" : '') !!}{!! ((config('app.max_results') > 500) ? ",'".config('app.max_results')."'" : '') !!}], - pageSize: {{ (($snipeSettings->per_page!='') && ($snipeSettings->per_page > 0)) ? $snipeSettings->per_page : 20 }}, - paginationVAlign: 'both', - queryParams: function (params) { - var newParams = {}; - for(var i in params) { - if(!keyBlocked(i)) { // only send the field if it's not in blockedFields - newParams[i] = params[i]; + $('.snipe-table').bootstrapTable('destroy').each(function () { + {{-- console.warn("Okay, what's 'this'?"); + console.dir(this); --}} + export_options = JSON.parse($(this).attr('data-export-options')); + export_options['htmlContent'] = true //always append this to the given data-export-options + + console.log("Export options on the table are:"); + console.dir(export_options) + + $(this).bootstrapTable({ + classes: 'table table-responsive table-no-bordered', + ajaxOptions: { + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } + }, + stickyHeader: true, + stickyHeaderOffsetY: stickyHeaderOffsetY + 'px', + undefinedText: '', + iconsPrefix: 'fa', + cookie: true, + cookieExpire: '2y', + mobileResponsive: true, + maintainSelected: true, + trimOnSearch: false, + showSearchClearButton: true, + paginationFirstText: "{{ trans('general.first') }}", + paginationLastText: "{{ trans('general.last') }}", + paginationPreText: "{{ trans('general.previous') }}", + paginationNextText: "{{ trans('general.next') }}", + pageList: ['10','20', '30','50','100','150','200'{!! ((config('app.max_results') > 200) ? ",'500'" : '') !!}{!! ((config('app.max_results') > 500) ? ",'".config('app.max_results')."'" : '') !!}], + pageSize: {{ (($snipeSettings->per_page!='') && ($snipeSettings->per_page > 0)) ? $snipeSettings->per_page : 20 }}, + paginationVAlign: 'both', + queryParams: function (params) { + var newParams = {}; + for(var i in params) { + if(!keyBlocked(i)) { // only send the field if it's not in blockedFields + newParams[i] = params[i]; + } + } + return newParams; + }, + formatLoadingMessage: function () { + return '

Loading... please wait....

'; + }, + icons: { + advancedSearchIcon: 'fa fa-search-plus', + paginationSwitchDown: 'fa-caret-square-o-down', + paginationSwitchUp: 'fa-caret-square-o-up', + columns: 'fa-columns', + refresh: 'fa-refresh', + export: 'fa-download', + clearSearch: 'fa-times' + }, + exportOptions: export_options, + + exportTypes: ['csv', 'excel', 'doc', 'txt','json', 'xml', 'pdf'], + onLoadSuccess: function () { + $('[data-toggle="tooltip"]').tooltip(); // Needed to attach tooltips after ajax call } - return newParams; - }, - formatLoadingMessage: function () { - return '

Loading... please wait....

'; - }, - icons: { - advancedSearchIcon: 'fa fa-search-plus', - paginationSwitchDown: 'fa-caret-square-o-down', - paginationSwitchUp: 'fa-caret-square-o-up', - columns: 'fa-columns', - refresh: 'fa-refresh', - export: 'fa-download', - clearSearch: 'fa-times' - }, - exportOptions: { - htmlContent: true, - }, - - exportTypes: ['csv', 'excel', 'doc', 'txt','json', 'xml', 'pdf'], - onLoadSuccess: function () { - $('[data-toggle="tooltip"]').tooltip(); // Needed to attach tooltips after ajax call - } - - }); + }); + }); });