DEV Community

Peter + AI
Peter + AI

Posted on

πŸš€ Understanding Uniface 10.4: The Power of $entityproperties Function

πŸ“ This blog post was created with AI assistance to help developers understand Uniface concepts better.

Hey developers! πŸ‘‹ Today we're diving into one of the most useful functions in Uniface 10.4: $entityproperties. This function is a game-changer when it comes to controlling how your application looks and behaves at runtime.

🎯 What is $entityproperties?

The $entityproperties function allows you to control the appearance of all occurrences of an entity while your application is running. Think of it as a way to change the "skin" of your data components dynamically! 🎨

This function works with different widget types like:

  • πŸ–ΌοΈ Default entity widgets in Form components
  • πŸ“Š Grid widgets
  • 🌐 Entity widgets in Dynamic Server Pages

πŸ“‹ How to Use It

The syntax is pretty straightforward:

$entityproperties {( Entity {, Properties} ) }

Or you can set properties like this:

$entityproperties ( Entity ) = PropertiesList

πŸ’‘ Real Examples

🎨 Changing Colors

Want to make your BOOK entity blue? Here's how:

$EntityProperties("BOOK") = "backcolor=dodgerblue"
Enter fullscreen mode Exit fullscreen mode

This simple line changes the background color of all BOOK entity occurrences to dodger blue! πŸ”΅

πŸ“Š Customizing Grid Appearance

Here's a practical example for Grid widgets:

operation exex
 ...
 $entityproperties = "RowHeadersVisible=F;RowNumbering=F;FieldBorders=T"
 edit
end; exec
Enter fullscreen mode Exit fullscreen mode

This code does three things:

  • ❌ Turns off row headers
  • ❌ Disables row numbering
  • βœ… Makes field borders visible

πŸ”§ Important Things to Remember

πŸ”„ Properties Reset: Every time you restart a component, properties go back to their default values. It's like pressing a reset button! However, if your Form component has "Keep Data in Memory" selected, properties stay put. πŸ’Ύ

🎯 Only Changed Properties: The function only returns properties that have been explicitly changed. It won't show you default values. πŸ“

⚠️ Error Handling: If something goes wrong, you'll get an empty string (""). The function doesn't give detailed error messages, so make sure your entity names are correct! πŸ›

πŸ† Why This Matters

The $entityproperties function gives you incredible flexibility in creating dynamic, responsive user interfaces. Instead of having static, boring forms, you can:

  • 🎨 Change colors based on data conditions
  • πŸ“ Adjust layouts dynamically
  • πŸ‘οΈ Show or hide elements as needed
  • 🎭 Create different themes for different users

This is especially powerful when combined with other Uniface functions like $CurEntProperties for even more control! πŸ”—

🎯 Quick Tips for Success

  • πŸ“ Always test your property strings before implementing
  • 🎨 Use meaningful color names like "dodgerblue" instead of hex codes when possible
  • πŸ” Remember that different platforms support different properties
  • πŸ’‘ Combine multiple properties using semicolons (;) as separators

That's a wrap! 🎬 The $entityproperties function is a powerful tool that can transform your Uniface applications from static to dynamic. Start experimenting with it today and see how it can improve your user experience! πŸš€

Happy coding! πŸ’»βœ¨

Top comments (0)