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)