Articles in this section
Category / Section

How to customize selected cell information in drill through dialog using JavaScript Pivot Table?

2 mins read

This article explains how to customize selected cell information in drill through dialog using JavaScript Pivot Table feature tour

Customizing selected cell information in drill through dialog

The drill through feature allows you to view the raw data of any pivot table cell in a pop-up window by double-clicking the cell. In this pop-up window, the row header, column header, and value header of the clicked cell are displayed at the top. These headers are framed based on the underlying data. However, you have the option to customize these headers based on your needs by utilizing the drillThrough event.

Here is a code snippet that guides how to customize selected cell information in the drill through dialog.

[index.js]

var pivotObj = new ej.pivotview.PivotView({
  allowDrillThrough: true,
  drillThrough: function (args) {
        // To customize row headers
        args.rowHeaders = args.currentCell.rowHeaders === ''? '': args.currentCell.rowHeaders.toString().split(
            pivotObj.dataSourceSettings.valueSortSettings.headerDelimiter).join(' > ');
        // To customize column headers
        args.columnHeaders = args.currentCell.columnHeaders === ''? '': 
            args.currentCell.columnHeaders.toString().split(
              pivotObj.dataSourceSettings.valueSortSettings.headerDelimiter).join(' > ');
        // To customize value headers
        var intl = new ej.base.Internationalization();
        var formattedString = intl.formatNumber(args.currentCell.value, {
          format: '##0.000',
        });
        let currentCellValue = args.value;
        let valueHeader = currentCellValue.replace(/\((\d+)\)/, () => `(${formattedString})`);
        args.value = valueHeader;
      }
});

In the above code, both row and column headers are modified to replace the default delimiter (i.e., -) with the (‘>’) symbol. The value header is also formatted to display the number in a specific format (for example, ##0.000).

The following screenshots show the difference between the drill through dialog with and without cell detail customization.

Screenshots:
Before customizing the cell information

dt-header-2.png

After customizing the cell information

dt-header.png

For a practical example of this code in action, you can refer to the following Sample in Stackblitz

Conclusion:
I hope you enjoyed learning how to customize selected cell information in drill through dialog.

You can also refer to our JavaScript Pivot Table feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Pivot Table example example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied