Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PowerBuilder Datawindow protect a field

Posted on 2011-03-01
7
4,092 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

860 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