How to create a parameter against a relation data field

Stimulsoft Reports.JS discussion
Post Reply
nexar
Posts: 31
Joined: Tue May 02, 2017 5:55 pm

How to create a parameter against a relation data field

Post by nexar »

I have the following data schema:

Code: Select all

<Tours>
  <id>
  <tourdesc>
  <tourcityid>
</Tours>

<Cities>
  <id>
  <citydesc>
  <countryid>
</Cities>

<Countries>
  <id>
  <countrydesc>
</Countries>
I have created a data source for each of these tables. I have then created a relationship for Tour_City and another City_Country.

Based on the above relationships I can extract the following information in a single data band as follows:

{Tours.id} {Tours.tourdesc} {Tours.Tour_City.citydesc} {Tours.Tour_City.City_Country.countrydesc}

I now need to provide a parameter where the user selects from the list of countries from the Countries.countrydesc and that brings up only those Tours which are in that country.

I created a variable called Country and linked it to the Data Column key = countries.id and value = countries.countrydesc. I now need to tell sql query to use this variable.....and that's the bit I can't do.

Please will you tell me how to do that.

Currently my query strings are :

select id,tourdesc, tourcityid, from tours.
select id, citydesc, countryid from cities.
select id, countrydesc from countries

All help gratefully received with thanks.
nexar
Posts: 31
Joined: Tue May 02, 2017 5:55 pm

Re: How to create a parameter against a relation data field

Post by nexar »

It's OK I've found out that the way to do this is to create a Filter on the Data band and then use the country.id through the relationships and make it equal to the variable. That then works fine.

However I would like to ONLY present a final pdf file to the client rather than via the viewer. I can arrange to request their choice of country.id via other programming ways. If I do that then how do I present to the report progammatically the filter parameter?

Thanks for your help.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to create a parameter against a relation data field

Post by Alex K. »

Hello,

You can use an additional variable which uses in the filter and set before rendering, exporting report.
You can find samples at the following link:
https://www.stimulsoft.com/en/samples/js

Thank you.
nexar
Posts: 31
Joined: Tue May 02, 2017 5:55 pm

Re: How to create a parameter against a relation data field

Post by nexar »

Hi Aleksey

I looked through all of the JS samples and I couldn't find any that dealt with parameters. There are a couple of videos which show how to work with parameters but not through code.

Please could you tell me which particular samples I should look at. Thanks.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to create a parameter against a relation data field

Post by Alex K. »

Hello,

You can use the following code to set the value for variable from code:

Code: Select all

report.dictionary.variables.getByName("variableName").valueObject = "your value";
Thank you.
nexar
Posts: 31
Joined: Tue May 02, 2017 5:55 pm

Re: How to create a parameter against a relation data field

Post by nexar »

Thanks very much for that info Aleksey. I'll have a try.

I'm beginning to realise that there is a LOT MORE functionality within the software than is described in the documentation, samples or videos. Is there anywhere I can get at the 'Object' models for the JS version please? That would allow me to understand what other functionality I could use.
Post Reply