Skip to content

Commit

Permalink
Fixed #1567
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Oct 25, 2017
1 parent 95c4255 commit 2fd4c7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/components/common/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class Column implements AfterContentInit{
@Input() scope: string;
@Input() style: any;
@Input() styleClass: string;
@Input() exportable: boolean = true;
@Input() headerStyle: any;
@Input() headerStyleClass: string;
@Input() bodyStyle: any;
Expand Down
10 changes: 6 additions & 4 deletions src/app/components/datatable/datatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2523,8 +2523,9 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni

//headers
for(let i = 0; i < this.columns.length; i++) {
if(this.columns[i].field) {
csv += '"' + (this.columns[i].header || this.columns[i].field) + '"';
let column = this.columns[i];
if(column.exportable && column.field) {
csv += '"' + (column.header || column.field) + '"';

if(i < (this.columns.length - 1)) {
csv += this.csvSeparator;
Expand All @@ -2536,8 +2537,9 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
data.forEach((record, i) => {
csv += '\n';
for(let i = 0; i < this.columns.length; i++) {
if(this.columns[i].field) {
csv += '"' + this.resolveFieldData(record, this.columns[i].field) + '"';
let column = this.columns[i];
if(column.exportable && column.field) {
csv += '"' + this.resolveFieldData(record, column.field) + '"';

if(i < (this.columns.length - 1)) {
csv += this.csvSeparator;
Expand Down
8 changes: 8 additions & 0 deletions src/app/showcase/components/datatable/datatabledemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ <h3>Properties</h3>
<td>null</td>
<td>Style class of the column, can be override with headerStyleClass, bodyStyleClass and footerStyleClass.</td>
</tr>
<tr>
<td>exportable</td>
<td>boolean</td>
<td>true</td>
<td>Whether the column is included during data export.</td>
</tr>
<tr>
<td>headerStyle</td>
<td>object</td>
Expand Down Expand Up @@ -912,6 +918,8 @@ <h3>Data Export</h3>
&lt;button type="button" pButton icon="fa-file-o" iconPos="left" label="CSV" (click)="dt.exportCSV(&#123;selectionOnly:true&#125;)"&gt;&lt;/button&gt;
</code>
</pre>
<p>In order to exclude a column from the csv, use [exportable]="false" on p-column.</p>

<p>See the <a [routerLink]="['/datatable/export']">live example.</a></p>

<h3>Scrolling</h3>
Expand Down

0 comments on commit 2fd4c7e

Please sign in to comment.