on 06-10-2016 12:59 AM
Hi PB Gurus,
I'm trying to get the current row of a column(dddw style) in DW under the clicked event.
I use this:
if (GetRow()=CurrentRow(), RGB(255,255,0), RGB(0,255,255))
But I got Unknown Function Name CurrentRow
If I place this In rowsfocuschanged / rowsfocuschanging event
if (GetRow()=CurrentRow(), RGB(255,255,0), RGB(0,255,255))
It ran. But it throws I'm in row 1, even if I select another record in my dddw.
Kindly, shed some light on this.
TIA,
CurrentRow() is a datawindow object expression function and not a powerscript function.
To get current row in an event, you need a datawindow powerscript function:
GetRow()
Additionally in the clicked event, if you want the clicked row there is an argument to the script called row
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan,
Can I ask why you need the current or selected row in the drop down datawindow?
There are fundamentally two different uses of a drop down datawindow.
In a datawindow when for example you want to display an employee name or number rather than the primary key of the employee table you have two choices; you can either do a join in your select on the primary key or you can create a datawindow that can be used to translate the primary key into the employee name or number. This datawindow will have the primary key and the employee name and number. You can use this a drop down datawindow in another datawindow. So if you have a report you select what ever data but don't join the employee table. You select the foreign key instead. You then assign that column with edit style dddw and map the data and display columns so the user does not see the database keys. Even though it's called drop down, you actually don't drop down.
The other use is when you want use to enter some data, including choosing an employee from a drop down list (datawindow). You do exactly the same plus you set the tab order so the user can open (drop down) the list and choose.
In both cases your base datawindow contains the foreign key.
So why do you want to know the row number of the dddw?
Lars 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Lars, thank you for the insight.
I need to pass or get the value of a column/s of dddw in a dw.
I just asked for the row number, because if I can get one value of a column in a dddw,
I can also get the values from other columns in my dddw.
I just needed to know how to get one column value in a dddw, to have an idea on how to deal with other columns. That's all.
Maybe you need this:
datawindowchild lwdc
long ll_row, ll_id
string ls_employee_id
// check the user clicked a row
if row < 1 then return
// get a reference to the drop down datawindow
if GetChild ( 'payment_person_id' ,ldwc ) < 0 then return
// what is the value in the base datawindow
ll_id = this.GetItemNumber ( 1 , 'payment_person_id' )
// find that value in the dropdown buffer
ll_row = ldwc.Find ( 'person_id=' + string(ll_id), 1 , ldwc.RowCount() )
if ll_row > 0 then
ls_employee_id = ldwc.GetItemString ( ll_row , 'employee_id' )
end if
The primary objective of the dropdowndatawindow edit style is to link the column from the main datawindow to the primary key column of the dddw (Data Column) in order to easily obtain the value of one of the other columns of the dddw (Display Column) which would normally be the description of the record from the lookup table. The dddw edit style automatically fetches this value for you and places it in to main datawindow buffer.
If the case is where you have additional columns in the dddw that you want to access then Lar's method is the correct one, although to achieve the same objective I prefer not to define additional columns in the dddw but to instantiate a separate datastore which I'll use to fetch the complete record of the lookup table and grab the information from there.
The argument in the clicked event is row, not currentrow.
The event rowfocuschanged receives currentrow.
The event rowfocuschanging receives currentrow and newrow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The events in question applies to the datawindow control that hosts the main datawindow. If you have only one row in the main datawindow currentrow will always return 1.
For the dddw that is referenced by the column of the main datawindow you would need a different mechanism, if there exists one, to obtain the current row when clicking on a row in the dddw. I've never done this but I'll investigate and if I find something I'll let you know. A lead may be to use the DropDown event, which is not a standard PB datawindow event, which may contain information about the current row.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.