cancel
Showing results for 
Search instead for 
Did you mean: 

PB Newbie - CurrentRow() is unknown function name

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi, Lars that's very helpful!

Can you kindly show me how?syntax perhaps.

I need to get the current row of a column in dddw under my dw and show the value in a messagebox...

Thank you very much!

Former Member
0 Kudos

In the clicked event:


MessageBox ( 'Clicked Event' , 'Clicked row: ' + string (row) + &

     '~r~nCurrent row:' + String ( getrow() )  + &

     '~r~nObject: ' + string ( dwo.name))

I suspect you will get

Clicked row: 1

Current row: 1

Object: person_id

Former Member
0 Kudos

Thank you, Lars!

But if I select other row in my dddw it still throws current row: 1

I need to return the number of the current selected row.

e.g.

I clicked row 5 it shows  current row: 5

if I clicked row 10 it shows current row:10

Thank you so much Lars! such a great help!

Answers (2)

Answers (2)

Former Member
0 Kudos

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 🙂

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

ricardojasso
Participant
0 Kudos

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.

Former Member
0 Kudos

Absolutely. Encapsulate into a reuseable nvo with a ds you can you use to share data with you dropdown. Cache and even methods to get the addtitional column values.

ricardojasso
Participant
0 Kudos

The argument in the clicked event is row, not currentrow.

The event rowfocuschanged receives currentrow.

The event rowfocuschanging receives currentrow and newrow.

Former Member
0 Kudos

Hi Ricardo,

How can I pass  the value of currentrow in the rowfocuschanged event in a messagebox perhaps?

TIA,

ricardojasso
Participant
0 Kudos

When you script in the rowfocuschanged event the variable currentrow is available to you to use it as you wish:

event rowfocuschanged (long currentrow) returns long [pbm_dwnrowchange]

MessageBox('RowFocusChanged', 'Current row: ' + string(currentrow))


Former Member
0 Kudos

That's what I did earlier, Ricardo.

But it throws the same row value even if I selected another row in my dddw.

How can I pass the currentrow value as I select a new row in my dddw?

TIA,

ricardojasso
Participant
0 Kudos

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.