How can i change Columns's Caption Name in PivotView

I am facing a challenge with pivot grid actually i want to show caption by some other data table Column here is a code that i want to change with  DYNAMICVALUE please check.

---------------------------------------------------------------

@Html.EJS().Button("excel").Content("Export To Excel").IsPrimary(true).Render()

@Html.EJS().PivotView("pivotview").Width("100%").Height("290").DataSourceSettings(dataSourceSettings => dataSourceSettings.DataSource((System.Data.DataTable)ViewBag.Data.Tables[0]).ExpandAll(false).EnableSorting(true)

   .FormatSettings(formatsettings => { formatsettings.Name("StateName").UseGrouping(true).Add(); })

   .Rows(rows => { rows.Name("SecName").Add(); rows.Name("SubSecName").Add(); rows.Name("IndicatorName").Add(); })

   .Columns(columns => { columns.Name("StateName").Add(); })

   .Values(values => {

   values.Name("ColVal1").Caption("DYNAMICVALUE").Add();

   values.Name("ColVal2").Caption(" DYNAMICVALUE ").Add();

   values.Name("ColVal3").Caption(" DYNAMICVALUE ").Add();

   })).GridSettings(new PivotViewGridSettings { ColumnWidth = 140 }).AllowExcelExport(true).Render()

---------------------------------------------------------------------------


please help me out as early as possible

Thanks and regards

RAVI



1 Reply 1 reply marked as answer

SS Saranya Sivan Syncfusion Team March 8, 2021 05:12 PM UTC

Hi Ravi, 
  
Based on your requirement we have prepared a sample to change the caption of the value field on a button click. Please check the below sample for your reference. 
  
  
Code Snippet: 
  
   document.getElementById('caption').onclick = function () { 
        pivotObj = document.getElementById('PivotView').ej2_instances[0]; 
        pivotObj.setProperties( 
            { 
                dataSourceSettings: { 
                    values: [{ name: "Sold", caption: "Products Sold" }, 
                    { name: "Amount", caption: "Products Amount" }] 
                } 
            }, 
            true 
        ); 
        pivotObj.refresh(); 
    } 
  
We hope the above sample meets your requirements. Please let us know if you have concern. 
  
Regards, 
Saranya Sivan. 



Marked as answer
Loader.
Up arrow icon