Power User Feature: Enable/Disable buttons

Actions you can use in your projects.

Power User Feature: Enable/Disable buttons

Postby Clifton » Sun Apr 12, 2015 10:10 am

Suppose you have a series of several buttons on a page and you need to enable/disable either certain ones or all of them all at once.

This is REALLY messy and can potentially introduce errors in your actions!!!

Image 1.png
Messy Action Sequence
Image 1.png (96.4 KiB) Viewed 4335 times

Instead let pgTBObjSet() do all the work for you. If you group the buttons into a group and name it something like "Control_Buttons", then this single action will enable or disable the all the buttons in one operation!!
NOTE: In the example below, set the parameter parseGroup = true. This means that each item in the group will have their enabled property set to false.

Image 3.png
pgTBObjSet() Makes it EASY!
Image 3.png (131.18 KiB) Viewed 4335 times

Which action sequence do you feel is easier and faster to implement?
Advantages:
  • Automatically takes into account added or deleted buttons from the group. You will not have to edit your code if you modify the group.
  • If a button is deleted from the group, the former action sequence will throw a runtime error. However, the PowerPac function pgTBObjSet() will gracefully take into consideration the removed button and never throw an error.
  • Makes it easier to follow the action logic and later make adjustments to the code.
  • Works just as effectively with many other supported object types and properties. (Not just buttons; try it with fields too.)
  • Effectively improves bandwidth when your page loads.

What if you want to disable all EXCEPT one or two buttons?
Solution: Just add the object property set actions to follow the global effect of pgTBObjSet() like this:

Image 4.png
Enabling only certain buttons
Image 4.png (93.61 KiB) Viewed 4333 times

Can it get any easier!!
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Return to Action Editor Examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron