Page 1 of 1
How to use a String Dictionary
Posted: Sun Sep 10, 2017 6:32 pm
by MartinRoth
I have a huge Dictionary<string,string> with thousands of entries, that I would like to use in a report. How do I use a given entry in the Dictionary as a label in the designer?
I tried several things, e.g.
var myDict = new Dictionary<string,string>();
myDict.Add ("test", "Le Teste");
myReport.RegBusinessObject ("Language", myDict);
myReport.Dictionary.SynchronizeBusinessObjects (1);
and then in the Report I add the text {Language["test"]}, but this is redered empty.
TIA Martin
Re: How to use a String Dictionary
Posted: Wed Sep 13, 2017 5:58 pm
by Alex K.
Hello,
Sorry for the delay with response.
You can use the following expression:
Code: Select all
{FirstIf(Language.Value,Language.Key == "test")}
Thank you.
Re: How to use a String Dictionary
Posted: Thu Sep 14, 2017 12:18 pm
by MartinRoth
Thanks for the reply. It seems your solution only works if the dictionary only contains one entry. If I have
var myDict = new Dictionary<string,string>();
myDict.Add ("test", "Le Teste");
myDict.Add ("some other test", "une autre teste");
myReport.RegBusinessObject ("Language", myDict);
myReport.Dictionary.SynchronizeBusinessObjects (1);
in the code and
{FirstIf(Language.Value,Language.Key == "test")}
in the report, this text is rendered empty. Same with {FirstIf(Language.Value,Language.Key == "some other test")}
Any advice?
TIA
MArtin
Re: How to use a String Dictionary
Posted: Fri Sep 15, 2017 6:43 am
by Alex K.
Hello,
We couldn't reproduce this bug.
Please clarify which product and version are you use?
Thank you.
Re: How to use a String Dictionary
Posted: Fri Sep 15, 2017 2:04 pm
by MartinRoth
I'm using Version 2017.1.3 from 11 May 2017, ASP.NET, JS
Please see this project:
https://drive.google.com/file/d/0B9TGY2 ... sp=sharing
In Dictionary.aspx, Dictionary.mrt is loaded and a Dictionary>string,string> is created with 3 entries.
The report has 3 text lines with the expression {FirstIf(Language.Value,Language.Key == <WHATEVER_KEY>)}
only the first one is rendered.
TIA, Martin
Re: How to use a String Dictionary
Posted: Fri Sep 15, 2017 3:07 pm
by Alex K.
Hello,
Unfortunately, in the JS version business objects are not supported. Sorry.
Thank you.
Re: How to use a String Dictionary
Posted: Mon Sep 18, 2017 1:48 pm
by MartinRoth
I'm not using JS, I'm using ASP.NET, as you can see in the project posted above.
Re: How to use a String Dictionary
Posted: Wed Sep 20, 2017 1:40 pm
by Alex K.
Hello,
This is a feature of business objects working. You should place for each Text component additional DataBand with linking to the business object. In this case, most easy is to use variables instead dictionary object.
Thank you.