Title: Did you know that you can protect a Grid from editing without coding any event?

When a Grid resource (row, column or cell) has to be protected from editing, it's normal practice to
1. assign an event procedure to the Grid (if not yet available),
2. insert the handling of the MSG-BEGIN-ENTRY event,
3. check if the X/Y coordinates that generated the events match with the area you wish to protect and, if so
4. Make the event fail by setting the EVENT-ACTION registry

Despite not beeing wrong, this approach is not optimized especially in a thin client environment, as it generates client/server traffic for the event handling (the UI on the client informs the runtime on the server that an event occurred, the runtime responds that the event should fail and so the UI makes it fail).
There is a quicker and more optimized approach to protect a Grid area from editing. You can do it by setting one of the following properties to the value of "1".
- PROTECTION (to protect the whole Grid),
- ROW-PROTECTION (to protect one or more rows),
- COLUMN-PROTECTION (to protect one or more columns),
- CELL-PROTECTION (to protect one or more cells)

So, a code like this (written in the Grid Event Procedure):

  evaluate event-type
  when msg-begin-entry
  |first two columns are read-only
       evaluate event-data-1
       when 1
            set event-action to event-action-fail
       when 2
            set event-action to event-action-fail
       end-evaluate
  end-evaluate

Can be changed to:

  |first two columns are read-only
  modify screen-1-gr-1 x = 1, column-protection = 1
  modify screen-1-gr-1 x = 2, column-protection = 1

(written in the program Procedure Division, after the DISPLAY of the Grid)
And your program will be more optimized.

Authored by: Veryant Support on Wed, Jun 29th, 2016 at 7:00 PM
This question has been viewed 4165 times so far.
Online URL: http://support.veryant.com/support/phpkb/question.php?ID=275

Powered by PHPKB Knowledge Base Software