logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ptsepeli  
#1 Posted : Friday, June 28, 2019 3:13:57 PM(UTC)
ptsepeli

Rank: Newbie

Groups: Registered
Joined: 2/14/2019(UTC)
Posts: 5
United Kingdom
Location: Harpenden

Was thanked: 1 time(s) in 1 post(s)
I am trying to find a way to change the Name of a column in the reports table based on values in the database.
For example I have two db fields (Cat1 & Cat2) that in one case could be used to hold Country & Town and in another Name & Surname or anything else.

I had a play with the custom enumerated list but I guess this is for the values and not the title.

Is there a way of finding what are the methods and properties of the objects in the razor scripts? I believe the solution to my problem is in model.Elements but I have no way of knowing what is available to try.

Congratulations on the great product!

Thank you
epf  
#2 Posted : Monday, July 1, 2019 7:44:00 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 676
Switzerland

Thanks: 12 times
Was thanked: 116 time(s) in 113 post(s)
As a general rule: try to do it in SQL, then display the result in SR.
Once you have a SELECT SQL statement that works, it is easy to display it in SR.

So, for me you have to do this in SQL first, as the result table will have only 1 column title,
you have to present a final table to SR having either a column named 'Col1' or 'Col2', it should be easy to do this in SQL.


If you want to do it in SR with C#, you have 2 options:
Modify the result table in the 'Final Script' of you model, check the sample '54-Final Script - Change result table'.
Use a custom the template of the 'Data Table' view and change the HTML generated.
ptsepeli  
#3 Posted : Tuesday, July 2, 2019 3:58:30 PM(UTC)
ptsepeli

Rank: Newbie

Groups: Registered
Joined: 2/14/2019(UTC)
Posts: 5
United Kingdom
Location: Harpenden

Was thanked: 1 time(s) in 1 post(s)
Hi epf,
Thank for your reply.
I have chosen to take the option to modify the result table in the Final script.
I managed to modify the headers with some text (thanks to 54-Final Script) but I don't seem to be able to pull the values from the restriction and rename accordingly.

I have a restriction that has the Enum Col1: Country, Col2: Town. My column is named "Col1" and my goal is to rename it to "Country" based on the restriction.
My two questions are:
1. How can I access all the values from an Enum restriction and not only the selected ones which I know are in EnumValues?
2. How can I access the Identifier (Col1) and the Value (Country) pair from an Enum restriction?

Thanks for all your help
epf  
#4 Posted : Wednesday, July 3, 2019 7:16:55 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 676
Switzerland

Thanks: 12 times
Was thanked: 116 time(s) in 113 post(s)
Yes we have to publish the object model online,
Here is how to browse the enum definition of a restriction:

Code:

    //Display value from ID
    string enumDisplayVal = restriction.GetEnumDisplayValue(restriction.EnumValues[0]);

    //List enum values
    MetaEnum enumDef = restriction.EnumRE;
    foreach (MetaEV enumValue in enumDef.Values) {
        string enumId = enumValue.Id;
        string enumVal = enumValue.Val;
        string enumValRE = enumValue.ValR; //.Css, .Class
        
    } 

Edited by user Wednesday, July 3, 2019 7:22:31 AM(UTC)  | Reason: Not specified

ptsepeli  
#5 Posted : Wednesday, July 3, 2019 10:03:10 AM(UTC)
ptsepeli

Rank: Newbie

Groups: Registered
Joined: 2/14/2019(UTC)
Posts: 5
United Kingdom
Location: Harpenden

Was thanked: 1 time(s) in 1 post(s)
Well that did the Job!
It works thanks to your help epf.

Thank you very much.
I am including my (mostly yours) code in case someone wants to use it.

Code:
  
  ReportRestriction CatRestriction = model.GetRestrictionByName("Analysis Fields");  
  foreach (ResultPage page in model.Pages)
  {
    for (int col = 0; col < page.DataTable.Lines[0].Length; col++)
    {
        page.DataTable.Lines[0][col].Value = CatRestriction.GetEnumDisplayValue((string)page.DataTable.Lines[0][col].Value);
    } 
  }
thanks 1 user thanked ptsepeli for this useful post.
epf on 7/3/2019(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.