Using enginepopulated to set caption gets ovewritten

Hi,

I'm using https://ej2.syncfusion.com/angular/documentation/pivotview/field-list/#enginepopulated to fill the caption of the fields bot the bounded and the not bounded to the current report.

The problem is that it works good for those not bounded but the caption of the others is being replaced by what is set for example in the 'columns' field of the dataSourceSettings.

Should be possible to manually set the caption of all fields from enginePopulated?

This is an example of what I mean: https://stackblitz.com/edit/angular-nib4wh?file=app.component.ts
Check in the columns fields the item Year, I added to the enginePopulated but it's overwritten.

3 Replies 1 reply marked as answer

SS Saranya Sivan Syncfusion Team May 10, 2021 07:23 AM UTC

Hi Ezequiel Bertran, 
  
Kindly use the field mapping option to set properties for bound and unbound fields in report. Please find the code snippet and sample for your reference. 
  
  
  
Code Snippet: 
  
 this.dataSourceSettings = { 
      enableSorting: true, 
      rows: [ 
        { name: "Year" }, 
        { name: "Order_Source", caption: "Order Source" } 
      ], 
      columns: [{ name: "Country" }, { name: "Products" }], 
      valueSortSettings: { headerDelimiter: " - " }, 
      dataSource: data, 
      expandAll: false, 
      formatSettings: [{ name: "Amount", format: "C" }], 
      values: [{ name: "Amount", caption: "Sales Amount" }], 
      filters: [], 
      fieldMapping: [{ name: "Sold", caption: "Units Sold" }] 
    }; 
  
Please let us know if you have concerns. 
  
Regards, 
Saranya Sivan. 




EB Ezequiel Bertran May 10, 2021 06:44 PM UTC

Hi,

I tried your example but it only works for unbound fields? If I try to use fieldMapping for bound fields it doesn't take it.

I want to set a different caption for the bound fields 'Year'

thanks.


SS Saranya Sivan Syncfusion Team May 11, 2021 10:32 AM UTC

Hi Ezequiel Bertran, 
  
The main purpose of using field mapping is to set the properties for the unbounded fields. Even if any field properties defined in field mapping, the value set in the initial report for the same field will have the highest preceding. So you can set the caption for the bounded fields in the initial pivot report itself. Please find the sample and UG for your reference. 
  
Code Example: 
  
    this.dataSourceSettings = { 
      enableSorting: true, 
      columns: [ 
        { name: 'Year', caption: 'Production Year' }, 
        { name: 'Quarter' } 
      ], 
      values: [{ name: 'Amount', caption: 'Sold Amount' }], 
      dataSource: this.getPivotData(), 
      rows: [{ name: 'Country' }, { name: 'Products' }], 
      formatSettings: [{ name: 'Amount', format: 'C0' }], 
      expandAll: false, 
      fieldMapping: [{ name: 'Sold', caption: 'Units Sold' }], 
      filters: [] 
    }; 
  } 
  
  
  
Please let us know if you have concerns. 
  
Regards, 
Saranya S. 
 


Marked as answer
Loader.
Up arrow icon