How to set PivotViewFormatSettings programatically

I got a Pivot Table for report generation in my application. I use some currency and date values.

When the user creates a new report, I want to set the PivotViewFormatSettings for the values, so that they are displayed correctly wothout the need for the user to set the currency date format on his own. For the Date format this is even more urgent, since this is not configurable in the number format popup.


is there a way to set this programatically?

I tried to set it via pivotTable.DataSourceSettings.FormatSettings


2 Replies

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team August 15, 2022 04:04 PM UTC

Hi Florian,


Currently, we are analyzing your requirement at our end, and we will update further details within two business days (August 17, 2022).


Regards,

Angelin Faith Sheeba.



RG Rajeshkannah G Syncfusion Team August 16, 2022 01:30 PM UTC

Hi Florian,


Currently, we don’t have options to apply datetime format in the number format UI. Meanwhile, please refer the following code example to apply datetime format to a specific field in the pivot table programmatically.


Code Example:

<SfButton @onclick="onToggleClick">Apply Date Format</SfButton>

  <SfPivotView>

  <PivotViewDataSourceSettings>

   <PivotViewFormatSettings>

      <PivotViewFormatSetting Name="@formatSetting.Name" Type="@formatSetting.Type" Format="@formatSetting.Format"></PivotViewFormatSetting>              

         </PivotViewFormatSettings>

    </PivotViewDataSourceSettings>

      </SfPivotView>

 

@code{   

    private PivotViewFormatSetting formatSetting = new PivotViewFormatSetting

    {

        Name= "Initial",

        Type = FormatType.Number,

        Format = "N2"

    };

    private void onToggleClick(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)

    {

       formatSetting.Name = "PowUnits";

       formatSetting.Type = FormatType.DateTime;

       formatSetting.Format = "dd/MM/yyyy";  

  }

}


Output screenshot:


Meanwhile we have prepared sample for your reference.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PivotTable531206755


Please let us know if you have any concerns.


With regards,

Rajeshkannah Gopalakrishnan





Loader.
Up arrow icon