Runtime Style Loading

Stimulsoft Reports.JS discussion
Post Reply
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Runtime Style Loading

Post by BCS »

Is it possible to load a *.sts file for styling at run time similar to the external editor? In other words if I create a collection of styles, can I load them at run time via the save file and how would I switch between styles in that collection I just loaded.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Runtime Style Loading

Post by Lech Kulikowski »

Hello,

Yes, you can use the report.Styles.Load() method.

Thank you.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Runtime Style Loading

Post by BCS »

First of all I don't think you understood my question(s)...

1. Can l via Javascript, take a StiReport Object and load a style collection via an exported file into the StiReport, report.styles.load() has no parameters, I am looking for something like report.styles.load('Styles.sts')
2. If this is possible, how do I set the style index for the report, if the sts file has 5 styles and I want index 3, how do I do that.

I may have a few hundred reports and if I add a new style I can't just go open all of them one by one making this modification, its not feasible.

I only see:

loadFromJsonObject(jObject: StiJson) : void
loadFromXml(xmlNode: XmlNode) : void
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Runtime Style Loading

Post by Lech Kulikowski »

Hello,

Yes, you can use these methods in the JS:
loadFromJsonObject(jObject: StiJson)
loadFromXml(xmlNode: XmlNode)

> 2. If this is possible, how do I set the style index for the report, if the sts file has 5 styles and I want index 3, how do I do that.

You can load your styles in StiStylesCollection and work with it, remove, add etc

Thank you.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Runtime Style Loading

Post by BCS »

I will have to post an example of how I'm doing this and why its not working when I can get to it.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Runtime Style Loading

Post by Lech Kulikowski »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.
dlms_kz
Posts: 1
Joined: Wed Jul 27, 2022 8:00 am

Re: Runtime Style Loading

Post by dlms_kz »

I have the same question!
I want to programatically change the style right before the report generated.
How can I achieve this instead of writing a lot of rules for each of elements / bands / components?
(It must be somewhere some method as the designer does the same job..?!)
Thank you!
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Runtime Style Loading

Post by Lech Kulikowski »

Hello,

Please check the following code:
https://www.stimulsoft.com/en/samples/r ... -from-code

Thank you.
Post Reply