Solved

PowerBuilder Datawindow protect a field

Posted on 2011-03-01
7
3,777 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 2

Accepted Solution

by:
lbushby earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you guys
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now