SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Change Font Color of Disabled Button on SAP Screen Personas Flavor


SAP Screen Personas flavor developer can detect buttons with state change from active to passive, or enabled to disabled using script code on onAfterRefresh event so that in Javascript the button text font color can be changed to indicate the new status. For example, if a button is active or enabled, the font color is dark blue. So SAP flavor users can easily understand which buttons are enabled on the screen. And if a button is disabled, the font color of that button can be set to grey using disabledFontColor property. This functionality will enableS SAP Personas users to distinguish buttons and their functions that are enabled and disabled from each other.

On a SAP Screen Personas flavor, I want to control the active/passive or disabled status of layout butttons. Because when I add a text for the button and the button is disabled, by default the font color of the disabled button does not change. Although the icon if any assigned, is blurred to indicate that the button is disabled, this is not enough to notice changing state of button because the font color of the button text is unchanged.

I could finally accomplish to detect buttons that are disabled by testing their clickable property and by changing their disabledFontColor to a pale color or by setting to gray as in this SAP Personas tutorial. After completing this tutorial, you can have a flavor with buttons changing font colors with the change on their status from active to disabled or vise versa.

change SAP Personas active and disabled buttons font color

Using Javascript code in SAP Screen Personas flavor, editors can detect whether a button is active or deactivated on the flavor screen.
The value of clickable property of a screen element helps layout developers to detect if that element of button is active, enabled or disabled.

if( session.findById("wnd[0]/usr/btnSAVE").clickable == false ) {
 session.findById("wnd[0]/usr/btnSAVE").disabledFontColor = 'grey';
}

if( session.findById("wnd[0]/usr/btnREJECT").clickable == false ) {
 session.findById("wnd[0]/usr/btnREJECT").disabledFontColor = 'grey';
}
Code

In Javascript code, "sesion.findById() enables the script developer to reach to the button and its properties in code.

The clickable property of the buttons which returns boolean result (true or false) can be tested to determine dynamically if the button is active (enabled) or not (disabled) on the SAP Personas Screen flavor.

SAP Personas script code to check button disabled and set color

After the script code is completed for the buttons you want to control their state, save it and assign the new Javascript code to screen events as seen in following screen.

javascript assigned to onAfterRefresh SAP Screen Personas layout

Assign the script to onAfterRefresh screen event on SAP Screen Personas flavor.
onAfterRefresh event enables the developer to catch the state of buttons on every screen round-trip.
So that if a group of buttons are deactivated when a specific event is triggered, we can check and test every button onAfterRefresh script as I shared in this tutorial.
Changing the disabledFontColor property of the buttons can help to distinguish the active buttons from disabled passive buttons easily.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.