1. Tracy Lamb
  2. PowerBuilder
  3. Monday, 29 August 2022 22:18 PM UTC

I've got a couple of DW's that I want to be read-only under certain conditions.  I use PFC's  dw.of_SetUpdateable( FALSE ), but I also don't want any of the columns to be "clickable".  So, I add  dw.modify("Datawindow.ReadOnly=YES").  This work, but wondering if there's a better way to do the same thing?

~~~Tracy

PB2021, Build 1509, PFC12.5

 

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 10:43 AM UTC
  2. PowerBuilder
  3. # Permalink

"dw.modify("Datawindow.ReadOnly=YES")" is literally one line of code. Whatever the pfcs could do for you, it would still be one line of code. If you want a pfc function, just add it to you PFEMAIN library in the u_dw object.

regards.

Comment
  1. Tracy Lamb
  2. Tuesday, 30 August 2022 13:31 PM UTC
Well, it's 2 lines...

dw_ofSetUpdateable(FALSE) //needed to prevent the code from trying to update the dw

dw_modify("Datawindow.ReadOnly=YES") //needed to prevent any columns from being clicked into



I thought maybe there's another PFC function that does both. It's no problem, though.
  1. Helpful 1
There are no comments made yet.
PowerObject ! Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 17:08 PM UTC
  2. PowerBuilder
  3. # 1

If your dw has columns with Edit, InkEdit or RichTextEdit type, they support column.DisplayOnly attribute. You can set the column background color to indicate editability and at runtime can select the column contents and copy them but cannot edit the data. If would be great if this attribute is supported for other widget types such as EditMask, DDDW, DDLB, RadioButton, Checkbox, etc. consistently.

dw.ReadOnly is better in conjunction with of_SetUpdateable( FALSE ) to protect all columns and data but still have interactivity.

You can use RMB menu options to be able to copy column content, copy all rows, etc.

Comment
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 11:01 AM UTC
  2. PowerBuilder
  3. # 2

dw.enabled = false

Might do what you need with a little less coding. :)

Comment
  1. Miguel Leeuwe
  2. Tuesday, 30 August 2022 11:27 AM UTC
Yes, that could be useful too, but only if you only show one row on your dw. If you have more than one row, you'd completely lose (for example), the possibility to scroll and show other rows. Just my 2cts. Any right mouse button functionality would also be lost.

regards
  1. Helpful
  1. Benjamin Gaesslein
  2. Tuesday, 30 August 2022 11:31 AM UTC
Indeed, disabling will remove any user interactivity, which may or may not be desired.
  1. Helpful
  1. Tracy Lamb
  2. Tuesday, 30 August 2022 13:36 PM UTC
I agree with Miguel... If I set dw.enabled=false, then the user can't scroll on the form. Many forms have a few dozen rows.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 30 August 2022 01:49 AM UTC
  2. PowerBuilder
  3. # 3

Hi, Tracy - 

What we do in similar situations in our PFC application is is add a column in the DW's SELECT statement that does not map to any table/column and give it a name such as "protect_ind" ("ind" for "indicator") - and assign it a value in the SELECT statement (zero) that the Protect property of a column object can utilize and thereby protect the column from modification.

In each column's Protect property, we use a trivial expression like "protect_ind" with no If statement.

When conditions are such that the data values in a row need to be protected, the only thing the application has to do is set the value of the "protect_ind" column to 1, and voila, all of the column objects in that row are immediately protected.

Maybe you can use or adapt this technique for your purpose.

Best regards, John

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 29 August 2022 22:47 PM UTC
  2. PowerBuilder
  3. # 4

Hi Tracy;

 Personally, I think that the ReadOnly property is the best way "on the fly" but at design time, you can also set all the Tabs to Zero.  ;-)

Regards ... Chris 

Comment
  1. Tracy Lamb
  2. Tuesday, 30 August 2022 13:34 PM UTC
I agree. Much easier than editing tabs to zero then back again if circumstances changed.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.