Detecting Edit Mode in PI Vision Custom Symbols: A Developer Guide
Learn how to detect "Edit" or "Modify" mode in PI Vision custom symbols using `this.scope.layoutMode`, and implement dynamic symbol behavior based on the display state.
Roshan Soni
How to Detect Edit Mode in PI Vision Custom Symbols
Custom symbol development in PI Vision allows for highly interactive and tailored data visualizations. As a developer, you might want to adjust the appearance or behavior of your custom symbols when the display is in "Edit" or "Modify" mode—such as providing visual cues or enabling configuration elements exclusive to editors.
A common question arises: Is there a straightforward way to detect when a symbol is being edited?
The Solution: Using this.scope.layoutMode
When developing custom symbols in PI Vision, the framework provides a useful property: this.scope.layoutMode. This boolean value indicates whether the display is currently in an editable state.
- When
this.scope.layoutModeistrue, the display is in "Edit" or "Modify" mode. - When it's
false, the display is in viewing mode.
How to Use It
Within your custom symbol code (typically inside your symbol's controller or logic function), you can use this property as follows:
if (this.scope.layoutMode) {
// The symbol is in edit mode
// Provide editing UI cues or behaviors
} else {
// Standard viewing behavior
}
Example Use Cases
- Show handles or drag/drop interfaces only in edit mode
- Display configuration buttons or tooltips to guide editors
- Hide sensitive or distracting elements during display configuration
Tips for Developers
- Always check for the existence of
layoutModeon the scope, as the symbol's lifecycle might briefly present undefined states. - Use AngularJS
$watchwhen you need to react to edit mode transitions dynamically:
$scope.$watch('layoutMode', function (newVal) {
if (newVal) {
// Just entered edit mode
} else {
// Returned to view mode
}
});
Conclusion
Leveraging this.scope.layoutMode is the recommended way to detect and respond to "Edit" or "Modify" mode when creating custom symbols for PI Vision. This simple technique enables you to make your symbols more interactive and user-friendly for both editors and viewers.
Happy symbol development!
Tags
About Roshan Soni
Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.
No comments yet
Be the first to share your thoughts on this article.
Related Articles
Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead
A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.
Roshan Soni
Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB
Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.
Roshan Soni
Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?
Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.
Roshan Soni