Solved

PowerBuilder Datawindow protect a field

Posted on 2011-03-01
7
4,010 Views
Last Modified: 2013-12-26
Hello

I am not an expert in powerbuilder

I have a grid datawindow , 5 columns, is there away to protect a single cell from editing based on a condition ?

 I used protect but it will protect / unprotect  the whole column, even when protect used , the Enter stops working to Insert a second row (Down key event)

 I tried also in itemchanged event, (if the user  changed value the original value will override),
but didn't work also.

not necessary  "PROTECT" but any idea stops changes to this cell.

Thanks
0
Comment
Question by:m_jundi
7 Comments
 
LVL 2

Expert Comment

by:lbushby
ID: 35008160
You can use 'Protect' to achieve this but you need to use 'getrow()' as part of the expression to restrict to the row you are interested in.

e.g. entering the following as the 'protect' expression will protect the cell in row 3 only:

    if (getrow()=3,1,0)

0
 

Author Comment

by:m_jundi
ID: 35009028
Below is what I am using, please advise the correct syntax

setitem(row,"trns_price",w_new_price1)
dw_basic.object.trns_price.protect
0
 

Author Comment

by:m_jundi
ID: 35009032
Below is what I am using, please advise the correct syntax

setitem(row,"trns_price",w_new_price1)
dw_basic.object.trns_price.protect = true
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 2

Accepted Solution

by:
lbushby earned 150 total points
ID: 35012862
You need to replace the second line with something like this:

    dw_basic.object.trns_price.protect = '0~tif(GetRow()=' + string(row) + ',1,0)'

but you really need to understand how property expressions work in Powerbuilder otherwise that's probably not going to make a lot of sense.
0
 
LVL 2

Expert Comment

by:kmanoharnaik
ID: 35014874
hi,

whats that you want to do with that perticular cell? i mean what are the conditions to make that cell protected.

Generally protect expression at design mode works for entire row or entire column.
we can control if u can specify the row no, or if its new row or if its modified..so on..
please let me know the condition.

thanks
msn
0
 
LVL 3

Assisted Solution

by:loks
loks earned 100 total points
ID: 35020827
If you use protect directly on the column name then column will be protected for all the rows even though sometimes providing the row number since it is a grid DW.

So the easiest approach is to
1. create a dummy computed control as dummycol in the DW under detail band and mark it as invisible
2. Write an expression in the protect property of the column which you need to protect it dynamically in the datawindow.
IF(dummycol ='1',0,1)

3. Set the value programatically thorugh the code into this dummycol using setitem function depending upon your need.
dw_1.SetItem(RowNumber,'dummycol', 0) for unprotected and
dw_1.SetItem(RowNumber,'dummycol', 1) for protected.

Regards,
Loks
0
 

Author Closing Comment

by:m_jundi
ID: 35025395
Thank you guys
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question