Skip to content

Commit

Permalink
Add ability to have different exportConversions for specific export t…
Browse files Browse the repository at this point in the history
…ype fix #843 fix #844
  • Loading branch information
kartik-v committed Nov 3, 2018
1 parent c9bfdb2 commit ad1d198
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ Change Log: `yii2-grid`

## Version 3.2.7

**Date:** _under development_
**Date:** 03-Nov-2018

- (enh #846): Enhance Grid Grouping to better parse multi level group footers.
- (enh #843, #844): Add ability to have different exportConversions for specific export type.
- For example `from_pdf` and `to_pdf` will be used instead of `from` and `to`. If
only `to_pdf` is set then `from` and `to_pdf` will be used.
- (enh #840): Update Persian Translations.
- (enh #839): Enhancements to export form functionality.

Expand Down
14 changes: 9 additions & 5 deletions src/assets/js/kv-grid-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @package yii2-grid
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @version 3.2.6
* @version 3.2.7
*
* Grid Export Validation Module for Yii's Gridview. Supports export of
* grid data as CSV, HTML, or Excel.
Expand Down Expand Up @@ -253,19 +253,23 @@
$el.html(rawText);
});
var htmlContent = $table.html();
htmlContent = self.preProcess(htmlContent);
htmlContent = self.preProcess(htmlContent, expType);
$table.html(htmlContent);
$.each(cssStyles, function (key, value) {
$table.find(key).css(value);
});
return $table;
},
preProcess: function (content) {
var self = this, conv = self.exportConversions, l = conv.length, processed = content, c;
preProcess: function (content, expType) {
var self = this, conv = self.exportConversions, l = conv.length, processed = content, c,
from = c['from_' + expType] !== undefined ? c['from_' + expType] : (c.from !== undefined ? c.from : ''),
to = c['to_' + expType] !== undefined ? c['to_' + expType] : (c.to !== undefined ? c.to : '');
if (l > 0) {
for (var i = 0; i < l; i++) {
c = conv[i];
processed = $h.replaceAll(processed, c.from, c.to);
if (from.length && to.length) {
processed = $h.replaceAll(processed, from, to);
}
}
}
return processed;
Expand Down
4 changes: 2 additions & 2 deletions src/assets/js/kv-grid-export.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad1d198

Please sign in to comment.