1. John Valentin
  2. PowerBuilder
  3. Tuesday, 5 January 2021 17:15 PM UTC

I need to know how I can access columns/calculated fields/text objects in a trailer band as if they were in a detail band (since the row number in a trailer band is 0, I have no idea what to do). Also, there are multiple trailers so how do I know which trailer is being accessed?

 

For example, I have a report that pulls charges/payments for 3 different offices over a span of days.

The trailer is broken by office and date range. I have a column that displays the office value and a text object that displays the date range. What is the syntax of the code I would need to access the value of the column and the text in the static text object?

Accepted Answer
John Valentin Accepted Answer Pending Moderation
  1. Friday, 5 March 2021 15:54 PM UTC
  2. PowerBuilder
  3. # Permalink

Maybe I'm not explaining myself correctly.

 

If I have a report which has 3  groups defined with a  trailer band for each group and the user clicks on a computed field/static text object in one of the trailer groups, how do I know which trailer group the user clicked on? (the ordinal number of the group)

Comment
  1. mike S
  2. Friday, 5 March 2021 16:42 PM UTC
GetBandAtPointer
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 5 March 2021 18:08 PM UTC
  2. PowerBuilder
  3. # 1

Hi John;

  On the DW Control's "Clicked" event -  Have you tried the GetObjectAtPointer () method for this? You would then have the object's name in trailer and the row number.

Regards ... Chris

Comment
There are no comments made yet.
John Valentin Accepted Answer Pending Moderation
  1. Friday, 5 March 2021 15:54 PM UTC
  2. PowerBuilder
  3. # 2

Maybe I'm not explaining myself correctly.

 

If I have a report which has 3  groups defined with a  trailer band for each group and the user clicks on a computed field/static text object in one of the trailer groups, how do I know which trailer group the user clicked on? (the ordinal number of the group)

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 19 January 2021 16:31 PM UTC
  2. PowerBuilder
  3. # 3

When you click on a Button DataWindowObject (DWObject, or DWO) in a DataWindow, the ButtonClicked event in the DataWindow Control is going to fire. The "row" and "dwo" arguments to that event are supplied by PB. If the clicked button DWO resides in a Group trailer band (regardless of whether it is Group 1, 2, 3, etc.) the row argument will be the row number of the last row in that group. The Name property of the DWObject event argument dwo (i.e., dwo.Name) will identify the name of the button DWObject that was clicked.

If you instead click on something other than a Button DWObject, the Clicked event in the DataWindow Control is going to fire. This event also has a Long argument value named "row" and a DWObject argument named "dwo". If the DWObject resides in a Group trailer band, the row argument will be the row number of the last row in that group and dwo.Name will tell you the name of the DWObject that the user clicked. If the clicked object resides in a Group header band, the row argument will be the row number of the first row in that group.

If you click in a DataWindow but do not happen to click on any DWObject, the row number in the event will be zero and the dwo.Name will be "datawindow".

Regardless, once you have the row number, you can access the data values in that row using the GetItemXXXXXX methods, as Mike described.

I suggest you put the following code in the Clicked and/or ButtonClicked event of a DWC and experiment a little to get more comfortable with these events and the argument values that are passed to them:

MessageBox('Test','Row: '+String(row)+'~r~nObject Name: '+dwo.Name)

HTH

Regards, John

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 19 January 2021 15:08 PM UTC
  2. PowerBuilder
  3. # 4

columns/compute in a trailer - use dw.getitem (getitemdecimal, getitemstring). the row is last row in the group that the trailer band is for.  if you are using sum for the group it can be any row, but still it is typically the last row of the group.  so if you have only 2 groups, if you could use row 1 to get the trailer band value for the first trailer, and rowcount() to get the value for the 2nd trailer

 

text objects (not computes that have a text value, but a text object) - use describe if the text is static (not using an expression) or evaluate if the text object's value is using an expression.  part of evaluate is the row number, so that part is the same as above

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 5 January 2021 19:05 PM UTC
  2. PowerBuilder
  3. # 5

Are you trying to access this information in PowerScript or in a DataWindow expression???

If PowerScript; For the date range displayed in the text object:

Every text DataWindowObject (DWO) has a unique name that does not depend on the band or row in which it resides, so you can simply use dot notation or the Describe function to obtain it's Text property:

ls_text = dw_1.Object.textobjectname.Text -or-
ls_text = dw_1.Describe("textobjectname.Text")

For a DataWindow expression, the GetRow() DataWindow function returns the row number of the last row in a group if the object containing the expression resides in a group trailer band. (See "GetRow DataWindow expression function" in the PB Help).

HTH, John

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 5 January 2021 18:39 PM UTC
  2. PowerBuilder
  3. # 6

Hi John;

  That sounds like your DWO is of the Group Style. If so, you'll need to use the Evaluate() method to get the various related row information for each Group Trailer.  HTH

Regards ... Chris

Comment
  1. John Valentin
  2. Tuesday, 19 January 2021 14:37 PM UTC
Chris,















I know how do use evaluate, but I need to know more than just the value that the user clicked on.







Let me try to illustrate better.















Let's say I have report that given several offices and a date range, I have trailers that are grouped as following















Trailer 2 - office, date







(first record in trailer 2 for NY office)







office = NY







date = 1/2/2021







sales total = 100







(second record in trailer 2 for NY office)







office = NY







date = 1/3/2021







sales total = 50







(third record of trailer 2 for NY office)







office = NY







date = 1/4/2021







sales total = 25







Trailer 1 - office, startdate, end date







office = NY







daterange = 1/2/2021 - 1-4-2021







sales total = 175















Trailer 2 - office, date







(first record in trailer 2 for GAoffice)







office = GA







date = 1/2/2021







sales total = 30







(second record in trailer 2 for GA office)







office = GA







date = 1/3/2021







sales total = 15







(third record of trailer 2 for GA office)







office = GA







date = 1/4/2021







sales total = 10







Trailer 1 - office, startdate, end date







office = GA







daterange = 1/2/2021 - 1-4-2021







sales total = 55















IF I click somewhere in the trailer band 2 (let's say a button) in the Trailer 1 band for the GA office, how do I reference objects in this band? ( let's say each value displayed is a column, so how do I reference salestotal in Trailer 1 that has the GA office information? What's the syntax? trailer1.columnname? How do I reference the 2nd Trailer 1 instance and not the first one containing NY office information?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.