|
91 | 91 | }); |
92 | 92 |
|
93 | 93 | $menu.find('li').click(function () { |
94 | | - var type = $(this).data('type'), |
95 | | - doExport = function () { |
96 | | - if (typeof require === 'function') { |
97 | | - require(['tableexport'], function () { |
98 | | - that.$el.tableExport($.extend({}, that.options.exportOptions, { |
99 | | - type: type, |
100 | | - escape: false |
101 | | - })); |
102 | | - }); |
103 | | - } else { |
104 | | - throw new Error("RequireJS not found"); |
| 94 | + var li = this; |
| 95 | + if (typeof require !== 'function') { |
| 96 | + throw new Error("RequireJS not found"); |
| 97 | + } |
| 98 | + require(['tableexport'], function () { |
| 99 | + var type = $(li).data('type'), |
| 100 | + doExport = function () { |
| 101 | + that.$el.tableExport($.extend({}, that.options.exportOptions, { |
| 102 | + type: type, |
| 103 | + escape: false |
| 104 | + })); |
| 105 | + }; |
| 106 | + |
| 107 | + if (that.options.exportDataType === 'all' && that.options.pagination) { |
| 108 | + that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () { |
| 109 | + doExport(); |
| 110 | + that.togglePagination(); |
| 111 | + }); |
| 112 | + that.togglePagination(); |
| 113 | + } else if (that.options.exportDataType === 'selected') { |
| 114 | + var data = that.getData(), |
| 115 | + selectedData = that.getAllSelections(); |
| 116 | + |
| 117 | + // Quick fix #2220 |
| 118 | + if (that.options.sidePagination === 'server') { |
| 119 | + data = {total: that.options.totalRows}; |
| 120 | + data[that.options.dataField] = that.getData(); |
| 121 | + |
| 122 | + var Table = typeof require === 'function' ? require('table') : null; |
| 123 | + selectedData = {total: that.options.totalRows}; |
| 124 | + selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections(); |
105 | 125 | } |
106 | | - }; |
107 | 126 |
|
108 | | - if (that.options.exportDataType === 'all' && that.options.pagination) { |
109 | | - that.$el.one(that.options.sidePagination === 'server' ? 'post-body.bs.table' : 'page-change.bs.table', function () { |
| 127 | + that.load(selectedData); |
| 128 | + doExport(); |
| 129 | + that.load(data); |
| 130 | + } else { |
110 | 131 | doExport(); |
111 | | - that.togglePagination(); |
112 | | - }); |
113 | | - that.togglePagination(); |
114 | | - } else if (that.options.exportDataType === 'selected') { |
115 | | - var data = that.getData(), |
116 | | - selectedData = that.getAllSelections(); |
117 | | - |
118 | | - // Quick fix #2220 |
119 | | - if (that.options.sidePagination === 'server') { |
120 | | - data = {total: that.options.totalRows}; |
121 | | - data[that.options.dataField] = that.getData(); |
122 | | - |
123 | | - var Table = typeof require === 'function' ? require('table') : null; |
124 | | - selectedData = {total: that.options.totalRows}; |
125 | | - selectedData[that.options.dataField] = Table && that.options.maintainSelected ? Table.api.selecteddata(that.$el) : that.getAllSelections(); |
126 | 132 | } |
127 | | - |
128 | | - that.load(selectedData); |
129 | | - doExport(); |
130 | | - that.load(data); |
131 | | - } else { |
132 | | - doExport(); |
133 | | - } |
| 133 | + }); |
134 | 134 | }); |
135 | 135 | } |
136 | 136 | } |
|
0 commit comments