Dear visitor, despite the COVID-19 outbreak, our team continues operating at full speed.

Also, here is the form where you can apply for a special discount and we will contact you with possible options. Stay safe and continue achieving your business goals.

Fill the form
Get Free Trial
Get Free Trial

Customize field names with different names.

kumar asked on June 27, 2016

Hi,
My array consists of these fields : [{“legal entity“: “Entity1″,”amount“: 113,”value“: 888},{“legal entity“: “Entity2″,”amount“: 33444,”value“: 556}];
Can I customize/map the field names with different names?
Example: I wanted to display with column names with disfferent case: Legal Entity      Amount       Value
Please suggest on this.
Thanks & Regards,
Sunilkumar.V

9 answers

Public
Roman Petrusha Flexmonster June 28, 2016

Hi!

Yes, it’s possible. You can define it in the first record of JSON data:
{
    “Color”: {type: “string”},
    “M”: {type: “month”, caption: “Month”},
    “W”: {type: “week”, caption: “Week”},
    “country”: {caption: “Country”},
    “Price”: {type: “number”},
    “Discount”: {type: “number”}
}

Please look at this sample: https://jsfiddle.net/tua7owjs/37/
Regards,
  Roman

Public
kumar October 25, 2016

Hi,
 
As per the guidelines, I have made the changes into our project and deployed into server.
My requirement is just converting the attribute name to different case that’s why I am only using “caption” where I mentioned my desired name to display.
 
Example: “city” to “CITY”, “steps” to “Steps”
 
Issue:
After made that change, even numeric columns are converting to string type and we are not able to access all aggregated functions in measures section.Even, some of the string data type attributes we would like to see them as measures(like “Steps”) when we move it to measures section. But,now everything is treated as string in the component by this change.
 
Why “type” is mandatory when I convert the attribute from one case to another?
Our requirement is just converting to desired case. everything should work as expected before. Is there any possibility in the component to achieve this functionality?
 
Please look at the attached example which I have sent in an email and looking forward to hear the feedback as soon as possible.
 
Thanks & Regards,
Sunilkumar.V

Public
Iryna Kulchytska Flexmonster October 25, 2016

Hi Sunilkumar,
 
If you are using the first object in JSON array as meta object, type field is required. You can choose from the wide list of supported types described in this documentation article http://www.flexmonster.com/doc/data-types-in-json/. Please choose type “number” for numeric fields and caption parameter to change the name to the desired one as follows:

"_price": {type: "number", caption: "Price"}

In this case, all aggregated functions will be available for numeric fields in measures section.
 
Please let me know if the above approach works for you.
 
Kind regards,
Iryna

Public
kumar October 25, 2016

Hi Iryna,
[{“price”:1664,”steps”:”51″},{“price”:1190,”steps”:”113″},{“price”:174,”steps”:”117″}]
Thanks for the Response. Numeric fields are fine, no issue.
for above response, if I define like this : “steps”: {type: “number”, caption: “STEPS”}, it displays fine and treating it as measure field.
Will it affect anywhere by specifying like this?
Thanks & Regards,
Sunilkumar.V

Public
kumar October 26, 2016

Hi,
One more question.
if I don’t include any other field into meta object, it’s not binding to pivot table. so, Is all fields are mandatory to define in meta object(first object)? In below example “Steps” is not binding even though it has data. Is there any option to display “Steps” without specify it in meta object?
Example:
{
“account”:{type:”string”,”caption”:”Account”},
//”steps”:{type:”number”,”caption”:”Steps”},
“beginbalance”:{type:”number”,”caption”:”BeginBalance”}
},
{
“account”:”0001″,
“beginbalance”:174,
“steps”:”68.1,68.2,68.3″
}
Thanks & Regards,
Sunilkumar.V

Public
Roman Petrusha Flexmonster October 26, 2016

Hi Sunilkumar,

Yes, it’s necessary to define “Steps” in meta object. If you don’t want to show it the Field List please use type:hidden. I hope it will help you to resolve your problem.

Regards,
Roman

Public
Aaron March 18, 2020

Hi there,
Is it possible to set the captions for the field names using the pivot grid. You have suggested defining the names in the json but our users don’t have the ability to edit the JSON directly they will only be able to use the Pivot grid editor to define their reports.
Also in my case its a little different.
 [{“BusinessArea1″: “Cape Town”,”BusinessArea1Label”: “Cost Centre”}];

I would like to be able to define the Caption for BusinessArea1 to be the value of the field BusinessArea1Label. Is this possible and if so how would I achieve this using the Angular Pivot Grid component.
We are in the final stages of purchasing a license from you guys and this is a bit of a stumbling block for us as the Labels for the BusinessAreas are defined per customer of ours so we need to return it from the database as part of the model.
Regards,
Aaron

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster March 19, 2020

Hi Aaron,
 
Thank you for posting your question.
 
The hierarchy caption in the mapping can be changed at runtime by redefining the report with the updated mapping object:
 

let newReport = pivot.getReport();
newReport.dataSource.mapping.myhierarchy = {
type: "string",
caption: "New Caption"
};
pivot.setReport(newReport);

 
Pretty much the same way you can define the hierarchy caption to be the value of any other cell in the pivot table using the getCell() or getSelectedCell() API calls, for example:
 

let newReport = pivot.getReport();
newReport.dataSource.mapping.price = {
type: "string",
caption: pivot.getCell(3, 2).value
//OR
caption: pivot.getSelectedCell().value
};
pivot.setReport(newReport);

 
In case you would like to implement a more complex logic for retrieving the values of specific cells for the custom captions, we would also suggest considering the customizeCell function for such purposes. You can find more info on the mentioned API Calls by the following link: https://www.flexmonster.com/api/methods/
 
We’ve prepared a quick sample to demonstrate some of the mentioned approaches: https://jsfiddle.net/flexmonster/7tpbxgea/
 
Also, we were wondering if you could tell us a little bit more about your use case where the requested functionality of setting one field’s value as the other one’s caption is required. This will help us understand your situation better and ensure that we provide you with the most relevant information in the future.
 
Thank you in advance and looking forward to hearing from you.
 
Best regards,
Mykhailo

Public
Mykhailo Halaida Mykhailo Halaida Flexmonster 4 days ago

Hi Aaron,
 
Hope you’re doing well!
 
We are just checking in to ask if you’ve found our suggested solution helpful. Was it suitable for your use case? Perhaps, you have any additional questions here that you think we could help you with?
 
We would be happy to hear your thoughts.
 
Looking forward to hearing from you.
 
Best regards,
Mykhailo

Please login or Register to Submit Answer