Articles in this section
Category / Section

How to set the dropdowns as read-only option in the number formatting dialog

2 mins read

This article explains how to set the dropdowns as a read-only option in the Pivot Table number formatting dialog.

Set the dropdowns to read-only option in the number formatting dialog

The number formatting dialog allows you to specify the required number format that should be used in the values of the pivot table at runtime. However, in certain UI scenarios, you may want the drop-down options to be read-only in a number formatting dialog. This prevents any modifications, thus maintaining a consistent data display. You can achieve this by using the following code example:

document.getElementById('Formatting').addEventListener('click', () => {
  pivotObj.numberFormattingModule.showNumberFormattingDialog();
  // To set the values dropdown as a read-only option.
  pivotObj.numberFormattingModule.valuesDropDown.readonly = true;
  // To set the format type dropdown as a read-only option.
  pivotObj.numberFormattingModule.formatDropDown.readonly = true;
  // To set the grouping dropdown as a read-only option.
  pivotObj.numberFormattingModule.groupingDropDown.readonly = true;
  // To set the grouping decimal dropdown as a read-only option.
  pivotObj.numberFormattingModule.decimalDropDown.readonly = true;
});

In the above code, we are adding an event listener to the Formatting button. When this button is clicked, the showNumberFormattingDialog method is called, and this method will open the number formatting dialog.

Next, we set the readonly properties of the valuesDropDown, formatDropDown, groupingDropDown, and decimalDropDown instances to true. please refer the following screenshot, which portrays the results of the code snippet mentioned above.

Screenshot

number-format.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 set the dropdowns as read-only option in the number formatting dialog. To know more details about the number formatting feature, please refer to the following documentation. You can also refer to our Pivot Table feature tour 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