π 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"
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
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)