How to use a String Dictionary

Stimulsoft Reports.WEB discussion
Post Reply
MartinRoth
Posts: 10
Joined: Mon Sep 04, 2017 7:44 am

How to use a String Dictionary

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use a String Dictionary

Post 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.
MartinRoth
Posts: 10
Joined: Mon Sep 04, 2017 7:44 am

Re: How to use a String Dictionary

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use a String Dictionary

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Please clarify which product and version are you use?

Thank you.
MartinRoth
Posts: 10
Joined: Mon Sep 04, 2017 7:44 am

Re: How to use a String Dictionary

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use a String Dictionary

Post by Alex K. »

Hello,

Unfortunately, in the JS version business objects are not supported. Sorry.

Thank you.
MartinRoth
Posts: 10
Joined: Mon Sep 04, 2017 7:44 am

Re: How to use a String Dictionary

Post by MartinRoth »

I'm not using JS, I'm using ASP.NET, as you can see in the project posted above.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use a String Dictionary

Post 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.
Post Reply