Hi,Im adding some inline css based on some conditions using Extended Properties "style" attribute. For example:If(LR.List.Current.Rows.Column1Border = Entities.Borders.Full,"border: 1px solid #000;",If(LR.List.Current.Rows.Column1Border = Entities.Borders.Full,"border:None;",....
Then I also need to add some css to align text so below this I have some more ifs:
If(LR.List.Curent.Rows.Colum1Alignment = Entities.Alignments.Left,"text-align:left;",If(LR.List.Curent.Rows.Colum1Alignment = Entities.Alignments.Right,"text-align:right;",If(LR.List.Curent.Rows.Colum1Alignment = Entities.Alignments.Center,"text-align:center;",""))))))))
The issue is that the alignment ifs are not working because when one of the borders if becomes true the other ifs are not executed. Do you know how to properly solve this issue in outsystems? Thanks!
Hi Jake,
there's an alternative, instead of using the tag style, use the tag class.
You define the classes on the theme, and then you use similar logic. This way you can reuse these classes whenever you want, avoiding the inline CSS.
Example:
.Class1 { text-align: center; border:5px solid gray; }
.Class2 { text-align: center; }
Then on the element, instead of style, enter the class tag and use the If(IsActive,"Class1","Class2")
Best Regards,
Paulo Z
Hi Jack
Sorry, If I'm misunderstanding your question.
It looks like just concatenate two if will work.
If(LR.List.Current.Rows.Column1Border = Entities.Borders.Full,"border:None;",.... ))))+ If(LR.List.Curent.Rows.Colum1Alignment = Entities.Alignments.Left,"text-align:left;", .... )))))
Kind Regards,
Thanks, but that approach for this case is complex because there are a lot of conditions. Do you know if there is a better apprach than inline css in extended properties?
Thanks!
AFAIK, there is no magic word for this situation. Even you adopt Paulo's suggestion, using classes, but you need the same logic to decide which class to apply.
One suggestion is to wrap this logic into a function and use that istead.
Kind Regards
Hello Jake,
first of all, I would recommend not to use inline CSS, as a good practice, one should avoid this in order to keep the code clean and minimize performance issues.
Can you please provide the OML to check what is wrong with your approach?
Thanks, I dont have a valid OML to share. However do you know so how to handle the cases where is necessary to add css classes or css styles without using inline css?
For example a simpler scenario where is necessary to add some specific css only if IsActive is true:
If(IsActive,"text-align: center; border:5px solid gray;", "text-align: center;")
What is recommended approach in outsytems for theses cases instead of using the extended properties?
Thanks, that solution is more clean, however in terms of performance do you know if it would be the same or is also better? Thanks!
Also for the cases where is necessary concatenation like:
"margin-left:" +LR_Items.List.Current.Item.IndentationInPx + "px;"
For this cases there is also an alternative for inline css? Thanks!
In terms of performance, I would say that one cannot notice the improvement.
However, in my opinion, the fact that you keep your code DRY (Don't Repeat Yourself), having the classes reusable on the theme, is always a good practice and will result in better performances for the application on the long term.
Best regards,
HI How to write css code for Home and Home icon in Outsystems in Reactive.
Thanks ,Indu