diff --git a/doc/reference/View.md b/doc/reference/View.md index dc6f8187..3656959d 100644 --- a/doc/reference/View.md +++ b/doc/reference/View.md @@ -174,6 +174,25 @@ Set the fields for the CSV export function. By default, ng-admin uses the fields .stripTags(true) ]); +Be careful if you don't define explicitly your `exportFields` (and so the fields displayed in the datagrid will be used) you may have strange results with fields of type `template`! +For example, if you define: + + nga.field('picture', 'template') + .template('') + +The exported value will be : + + + +To fix that, you have to set your `.template` with a function : + + nga.field('picture', 'template') + .template((entry) => ``) + +In this case, the exported value will be : + + + * `exportOptions(Object)` Customize the CSV export format (quotes, delimiter, newline). The default options object is `{ quotes: false, delimiter: ",", newline: "\r\n" }`. diff --git a/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js b/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js index c3f5420f..66cb75b0 100644 --- a/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js +++ b/src/javascripts/ng-admin/Crud/misc/EntryFormatter.js @@ -36,7 +36,7 @@ export default class EntryFormatter { return function (entry) { return { name: label, - value: field._template(entry) + value: field.getTemplateValue(entry) }; }; case 'number':