Monday, September 12, 2011

Servoy TIP: Changing A Form's Style On-The-Fly!

I had a need the other day to change the style that was displaying on a form. My first thought was to just change all the object properties via scripting (a HUGE pain!). But, with the help of the SolutionModel (and controller.recreateUI() - in version 5.2+) - it was a snap.

Let's say you have two styles: "defaultStyle" and "fancyStyle" defined in your resources. If you use this code:
var myForm = solutionModel.getForm(controller.getName());
myForm.styleClass = "fancyForm";
Done! Be careful here - depending on how you designed your styles - things could get "wonky" (margins are the big culprit)... but man, did I mention how much I LOVE this tool?!

No comments:

Post a Comment