Use foreign key values for row/column captions in Pivot Table

Hi,

is it possible to use foreign key values for row and/or column captions in a Pivot Table, like in the DataGrid?

I've attached an example where I try to show the request.




Attachment: react2cau1p_71eef98e.zip

1 Reply

AP AngelinFaithSheeba PaulvannanRajadurai Syncfusion Team May 19, 2022 04:17 PM UTC

Hi Laurin,


Currently,  we don’t have option to display foreign key object in the pivot table. However, you can customize the row headers in the enginePopulated event. Please refer the below code example.


Code Example:


enginePopulated(args){

    for (var i = 0; i < args.pivotValues.length; i++) {

      for (var j = 0; args.pivotValues[i] != null && j < args.pivotValues[i].length; j++) {

        if (args.pivotValues[i][j] != null && args.pivotValues[i][j].axis == 'row') {

          for(let k=0; k<Object.keys(foreignKeyData).length; k++){

            if(args.pivotValues[i][j].actualText == foreignKeyData[k].id){

              args.pivotValues[i][j].formattedText = foreignKeyData[k].name

            }

          }

        }

      }

    }

  }


Meanwhile, we have modified your sample for your reference. Please find it from below link.


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


Please let us know if you have any concerns.


Regards,

Angelin Faith Sheeba


Loader.
Up arrow icon