How to change the measure name in JavaScript PivotClient?
This KB illustrates that how to change the measure name in JavaScript PivotGrid.
Solution:
In order to customize the measure name in the PivotGrid, refer to the following steps.
Step 1:
JSON data is framed based on the information such as current OlapReport and grid layout. The JSON data contains
- Updated and current OlapReport
- Values besides row header, column header, value cell and summary cell in the PivotGrid.
Step 2:
Once JSON records are framed by using the GetJsonData method, it is sent back to the client side for PivotGrid rendering. Here the measure name can be change as per the requirement.
Step 3:
On interrupting, values that are bound to PivotGrid for view are available in the dictionary under the key name PivotRecords. These values are extracted back and de-serialized.
Step 4:
Now, the de-serialized values are iterated. When the required measure name is found, it can be changed as desired.
C#
public Dictionary<string, object> InitializeGrid(string action, string currentReport, string gridLayout, string customObject) { OlapDataManager DataManager = new OlapDataManager(connectionString); DataManager.SetCurrentReport(OLAPUTILS.Utils.DeserializeOlapReport(currentReport)); var serJSON = olapClientHelper.GetJsonData(action, DataManager, gridLayout); var desJSON = serializer.Deserialize<List<Dictionary<string, string>>>(serJSON["PivotRecords"].ToString()); foreach (var item in desJSON) { if (item["Value"] == "Customer Count") { item["Value"] = "#Customer"; break; } serJSON["PivotRecords"] = serializer.Serialize(desJSON); return serJSON; } }
VB
Public Function InitializeGrid(ByVal action As String, ByVal currentReport As String, ByVal gridLayout As String, ByVal customObject As String) As Dictionary(Of String, Object) Dim DataManager As OlapDataManager = New OlapDataManager(connectionString) DataManager.SetCurrentReport(OLAPUTILS.Utils.DeserializeOlapReport(currentReport)) Dim serJSON = olapClientHelper.GetJsonData(action, DataManager, gridLayout) Dim desJSON = serializer.Deserialize(Of List(Of Dictionary(Of String, String)))(serJSON("PivotRecords").ToString()) For Each Dim item In desJSON If item("Value") = "Customer Count" Then item("Value") = "#Customer" Exit For End If Next item serJSON("PivotRecords") = serializer.Serialize(desJSON) Return serJSON End Function
Conclusion
I hope you enjoyed learning about how to change the measure name in PivotGrid
You can refer to our JavaScript PivotGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript PivotGrid 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, Direct-Trac, or feedback portal. We are always happy to assist you!