Change Default Pivot Report Name

The current default report name is "Sample Report". Is there any way to customize this?


3 Replies

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team September 23, 2022 08:10 AM UTC

Hi Brainweber,


Please see the code example below to save the default report with the desired report name.


Code Example:

  saveReport(args) {

      if (reports.length === 0 && args.reportName === 'Sample Report') {

        this.isNewReport = true;

        args.reportName = 'New Report';

      }

  }

 

  componentDidMount() {

    if (this.isNewReport || this.pivotObj.toolbarModule.currentReport === 'Sample Report') {

      this.isNewReport = false;

      this.pivotObj.toolbarModule.currentReport = localStorage.pivotviewCurrentReportName !== '' ? localStorage.pivotviewCurrentReportName

          : 'New Report';

      this.pivotObj.toolbarModule.reportList.value = localStorage.pivotviewCurrentReportName !== '' ? localStorage.pivotviewCurrentReportName

          : 'New Report';

    }

  }


Sample: https://stackblitz.com/edit/react-guvpwe?file=index.js


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.



BD Brainweber Dev September 26, 2022 06:05 AM UTC

Hi Team,

this.pivotObj is null during componentDidMount​ and is only accessible later.​

Is there any alternative solutions for this problem through localization? I believe the default report name is stored as a variable that can be overridden by L10n. Is that possible? I tried adding localization as per the documentation and couldn't manage to get it to work.


Regards



AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team September 27, 2022 09:19 AM UTC

Hi Brainweber,


Yes, you can change the default report name through the localization. Please refer the below code example.


Code example:

 L10n.load({

  'en-US': {

      'pivotview': {

          'defaultReport': 'Report',

      },

  }

});


Output screenshot:


Meanwhile, we have prepared a sample for your reference.


Sample: https://stackblitz.com/edit/react-guvpwe-mqbvmd?file=index.js


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba.


Loader.
Up arrow icon