PB 8.04
I have DW which has DDDW in one of it's columns.
This DDDW has 2 columns. One is string (display value) and the second is
numeric (data values).
Whe user select row in DDDW display value is displayed in DW. OK! Problem
is that in ItemChanged event of DW I call function Gettext(). What I get is
not display value but data value, so the same as is data argument for
ItemChanged Event.
Is there option that I get display value?
Regards
Tomaz
I can think about two solutions for your problem.
1.) Easy but maybe not what you like:
Add a computed field to the datawindow which shows
the content (string) from your dropDownColumn. The
expression for the computed field is:
lookupdisplay(<lookupColName>)
Then you get the visible value using getItemString()
for this computed field. Unforunately you can't get
the new value in the itemChanged event because
the it is'nt yet set into the column.
2.) A little more complex:
Get a reference to the dropDownDataWindow
using getChild(). Search in it for the actual data
value with find() and get the value from the display
column using getItemString()
HTH
Chris Werner
"Tomaz Kralj" <tomaz...@tpv-jc.si> schrieb im Newsbeitrag
news:41e4e026@forums-2-dub...
Here is my code from from pbm_dwndropdown event:
string mpopa,ms1
long mr1,mpos
mr1=this.GetRow()
if mr1<=0 or IsNull(mr1) then
return
end if
ms1=upper(trim(this.GetColumnName()))
if ms1='SIFRA' then
mpopa=this.GetText()
if trim(mpopa)='' or IsNull(mpopa) then
beep(2)
//return
mpos=0
else
mpos=pos('0123456789',left(trim(MPOPA),1))
end if
if mpos>0 then
mpopa=trim(mpopa)
mch_DS.Retrieve('S',mpopa+'%')
else
mpopa=trim(mpopa)
mch_ds.Retrieve('N',mpopa+'%')
end if
end if
//////////////////////////////////////////////////////
I have to tell you that column in DW has properties Allow Editing.
When I type something in edit control of DW and that do dropdown my variable
mpopa has text which I typed. OK!
I select on row in dropdown. OK!
When I dropdown the second time (but I don't change value in edit control) I
get in my variable mpopa datavalue of dddw.
I f I dropdown third time in my variable mpopa I get display value of ddw.
And so on.
What am I doing wrong?
Tomaz
"Chris Werner" <cw[please_no_spam]@f-s.de> je napisal v sporočilo
news:41e50834$1@forums-1-dub ...
sounds complicated. I can't find errors in your code and
be not sure what to expect as result of getText() for a
dddw column where the user have edited the content.
But because you're talking about the pbm_dwndropdown
event know instead of itemChanged like in your original
post I'd try the usage of a computed field which shows
the displayvalue of the dropdown.
Chris Werner
"Tomaz Kralj" <tomaz...@tpv-jc.si> schrieb im Newsbeitrag
news:41e5228c$1@forums-1-dub...
long ll_r
string ls_expr, ls_mpopa
if this.acceptText() = 1 then
ll_r = this.getRow()
if ll_r > 0 then
ls_expr = "lookupdisplay(sifra)"
ls_expr = "evaluate('" + ls_expr + "', " + string(ll_r) + ")"
ls_mpopa = this.describe(ls_expr)
// use ls_mpopa here ...
end if
end if
Should work like you want but keep in mind it
does'nt work in the itemChanged event.
HTH
Chris Werner
"Chris Werner" <cw[please_no_spam]@f-s.de> schrieb im Newsbeitrag
news:41e5370f@forums-2-dub...
Your code works perferct. The only problem is I get nothing in variable
ls_mpopa (ls_mpopa = this.describe(ls_expr)) when user type just part of
data. Do you have idea how to solve this?
Thanks
"Chris Werner" <cw[please_no_spam]@f-s.de> je napisal v sporočilo
news:41e53e81@forums-2-dub ...
if the user inputs something which is no
valid display value from the dropDownDW
no accordant data value can be found. So
the input is invalid (because you need a
numeric data value) and acceptText() fails.
But getText() should work in this case, so
the following may work for you:
ll_r = this.getRow()
if ll_r > 0 then
if this.acceptText() = 1 then
ls_expr = "lookupdisplay(sifra)"
ls_expr = "evaluate('" + ls_expr + "', " + string(ll_r) + ")"
ls_mpopa = this.describe(ls_expr)
else
ls_mpopa = getText()
end if
// use ls_mpopa here ...
end if
I'm in doubt if this is good code practice because
you use the displayed value of ls_mpopa but there
is no corresponding data value stored in the dataWindow.
If acceptText() fails no further action besides an
optional error message should happen.
Good luck
Chris Werner
"Tomaz Kralj" <tomaz...@tpv-jc.si> schrieb im Newsbeitrag
news:41e6218a$1@forums-2-dub...
This work. Another problem is that Itemchanged Event get fired after
Accepttext() is called. I would like to check data in Itemchanged event
after user select anything in dddw?
"Chris Werner" <cw[please_no_spam]@f-s.de> je napisal v sporočilo
news:41e63a91$1@forums-2-dub ...
that depends on what you want to achieve here. If
you want to process the diplay value only after the user
*successfull* changed the data, pbm_dwndropdown
is'nt the right plase to code that stuff because it fires before
the change. In this case you should code the itemChanged
event to do the checks you need and retrieve the display
value only in case the new data value is valid. Maybe you
can explain your goals more detailed?
Chris Werner
"Tomaz Kralj" <tomaz...@tpv-jc.si> schrieb im Newsbeitrag
news:41e64311$1@forums-2-dub...
I try to create visual user object of type Datawindow. Data object on this
DW is external DW with two columns: code (char 15) and description char(50).
On column code I have DDDW with 3 columns (id integer, code char(15),
description char(50)) Column id is datavalue and code is display value)
Column code in DW is editable.
What I would like to implement is:
1. User type part of code or nothing or complete code in column code. If
code is complete I would do select in database for id and descripton of
code, display descripton and trigger event which will do some other
procesing.
User could also click on DDDW and get all resaults from DB which starts like
they typed in column. User select row in DDDW and I do the same as at 1.
point.
In DB I have table "components" which has columns: Id integer
autoincrement,code char(15),description char(50). DDDW has SQL statement
with "...where code like :parameter"
I would like to use this object on many windows for searching for
components.
Could you sugest me how to do this?
Regards
Tomaz
"Chris Werner" <cw[please_no_spam]@f-s.de> je napisal v sporočilo
news:41e64d7f@forums-1-dub ...
there's something wrong either in your explanation
or in your implementation. You state that there is
an "external DW with two columns: code (char 15) ..."
but the dropDown is defined to use the *integer*
column id as data value. This does'nt match. I
think all that will be easier if you take the column
code from the dddw as both data value and display
value. Then getText() will always deliver the visible
value in the column. For the following I assume that
there is only one row in the external datawindow
because you've stated that the component is some
kind of a search dialog. Otherwise things would be
more complicated.
In the itemChanged event you can now check if the result
of getText() (or the data argument) is a valid display value
from your dropDown. If so do the processing you've described,
otherwise do nothing (or maybe clear the description in the
external dw).
In the pbm_dwndropdown event set a filter on the dddw
according to the result of getText().
For both functionalities you need a reference to the dddw
dataWindowChild. You can store it in an instance variable.
// declare the instance variable for the dddw:
dataWindowChild idwc_sifra
// constructor event, store ref to dddw:
this.getChild("sifra", this.idwc_sifra)
// itemchanged event:
long ll_r, ll_id
string ls_expr, ls_description
this.idwc_sifra.setFilter("")
this.idwc_sifra.filter()
ls_expr = "code='" + data + "'"
ll_r = this.idwc_sifra.find(ls_expr, 0, this.idwc_sifra.rowCount())
if ll_r > 0 then
// value is valid, get other values:
// don't need a retrieve here because
// the values are already loaded in the dddw
ll_id = this.idwc_sifra.getItemNumber(ll_r, "id")
ls_description = this.idwc_sifra.getItemString(ll_r, "description")
// and do some processing ...
else
// not found, clear description ...
end if
// pbm_dwndropdown event, filter the dropdown:
string ls_data, ls_expr
ls_data = this.getText()
ls_expr = "code like '" + ls_data + "%'"
this.idwc_sifra.setFilter(ls_expr)
this.idwc_sifra.filter()
The code above is not checked in a real PB environment,
it is just to show how you may achive what you're after.
Good luck
Chris Werner
"Tomaz Kralj" <tomaz...@tpv-jc.si> schrieb im Newsbeitrag
news:41e66b93$1@forums-1-dub...