Skip to Content
0
Aug 02, 2023 at 09:02 AM

Dynamic Styling (via Rules)

77 Views

Hello Experts,

I have use Blog for Dynamic styling via rule .

https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/features/fiori-ui/mdk/styling.html

I have use this code in rule :-


export default function GiveColor(clientAPI) { const control = clientAPI.getControl() control.setStyle('MyButton'); //css class name control.setStyle('MyButton', 'formcell'); //css class name and subcontrol}Styllig.less (code):-@mdkYellow1: #ffbb33;@mdkRed1: #ff0000;
.MyButton{ color: @mdkYellow1; background-color: @mdkRed1; }Main page: -"Controls": [ { "_Type": "Control.Type.FormCell.Button", "_Name": " formcell", "IsVisible": true, "Separator": true, "Styles": { "Button": "/KhataBook/Rules/ GiveColor.js" }, "Title": "formcell", "Alignment": "Center", "ButtonType": "Text", "Semantic": "Tint", "Image": "res://mdk_logo.png", "ImagePosition": "Leading"

So I am unable to use this code. I debug this code but getcontrol() not working.
Regards,Anjali