To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Responsiveness
Cancel

The CSS and HTML Secrets of DataFlex WebApps

Lesson 8 - Controls

A summary of the video course

In this lesson, we'll explore how controls are constructed in DataFlex, including their elements and how to apply styles to them.

Understanding Inline Styles

DataFlex sets certain inline styles for controls, making them challenging to override. These inline styles are primarily controlled by control properties that map to CSS properties.

Mapping Properties to Inline Styles

Some control properties map directly to inline styles, such as:

  • pbVisible: visibility - hidden
  • pbRender: display - none
  • piHeight: height - 200 px
  • pbFillHeight: height - 345 px
  • psTextColor: color - #003300;
  • psBackgroundColor: backgroudn: #CCCCDD;

These properties are used to style controls in the browser.

CSS Structure of Controls

Controls in DataFlex generate a specific CSS structure. The outermost div element always has the class ."WebControl" but additional classes are added based on the control type. The hierarchy of nested class names is crucial for styling.

Styling Labels

Each control in DataFlex typically has a label associated with it. The styles for labels are defined on the ".WebControl" class.

Styling Enabled and Disabled Controls

Controls can be enabled or disabled. Use the ".Web_Enabled" and ".Web_Disabled" classes to style these states differently.

Styling Focused Controls

To style controls that have focus, use the ".WebCon_Focus" class. This allows you to change the appearance of controls when they are selected.

Applying Custom CSS Classes

DataFlex controls offer a "psCSSClass" property that allows you to apply custom CSS classes to the outermost div element of a control. This enables you to create custom styles.

Creating Custom Styles

Add another view 'Custom Style'. We're adding a button.

Set a psCSSClass to BtnWarn.

Open the AppHTML with VisualStudioCode.

Open "application.css". Define styles for your custom CSS classes or control-specific selectors based on the class names and elements you want to target.

Testing Custom Styles

After creating custom styles in your "application.css" file, save it and ensure that the designer reflects the changes by right-clicking on the designer area and selecting "Refresh."

Overriding Default Styles

When creating custom styles, ensure that your selectors are more specific than the default styles to override them. Adding more class names to your selectors increases specificity.

Ensuring Style Reloading

To prevent browser caching issues while testing your custom styles, open the developer tools in your browser, go to the network tab, and check "Disable cache." This ensures your styles are always refreshed when you reload the page.

Confirming Custom Styles

Inspect the control in your browser's developer tools to verify that your custom styles have taken precedence over default styles.

You've learned how to work with controls, apply inline styles, and create custom styles in DataFlex. In the next lesson, we'll delve into making your web applications responsive within the DataFlex Framework.