1. Paweł Kasperek
  2. PowerBuilder
  3. Wednesday, 13 November 2024 11:45 AM UTC

Hi,

I have defined a DataWindow that exceeds the screen size and form. It is too long. During its validation, when there is an error, I want to position myself in a row that is outside the visible range. I'm using the SetColumn function. Unfortunately, the scroll bar remains at the top of the window and DataWindow. How can I programmatically move the scroll bar to the bottom of the DataWindow (window) to show the selected row?

Regards,

Pawel

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 14 November 2024 16:08 PM UTC
  2. PowerBuilder
  3. # 1

Hi Pawel;

  This has nothing to do with the Vertical Scroll bar (although, that would be the "long" way around to solve this challenge). Instead, you need to have a look at the DW Object's VerticalScrollPosition property instead to make this behaviour super easy to implement. The same goes for the HorizontalScrollPosition property as well if you  also need to scroll the DWO horizontally automatically as well.

   This code has been in my STD Framework for quite some time. You can see it in action in the OrderEntry Demo App built from the framework when interacting with the Employee (Master / Detail) dialogue. In the lower DW Control, the DWO is scrolled vertically and horizontally to keep the App user focused on the long set of detail DWO's columns as the various column focus changes.

   If you look into the frameworks ancestors for the base level DC ancestor, you will notice that it extends all DC's automatic VScroll / HScroll behaviours by the App developer setting either the ib_auto_vscroll and/or ib_auto_hscroll boolean property ON in the working (concrete) descendant DC. The code is actually implemented in the base ancestor DC named "vs_dc_detail_master" respectively. The use of these two variables is implemented in the "ItemFocusChanged" event so that any keyboard, mouse or SetColumn() command will fire this DC event. Then the ancestor code checks these two VScroll / HScroll boolean variables and if ON, implements the "DataWindow.VerticalScrollPosition = " and / or "DataWindow.HorizontalScrollPosition = " DWO code to make the DWO scroll. If it does, then the DC's scrollbars will autoamtically keep up.  ;-)

  If you are interested in this approach, please feel free to download the STD Framework's OrderEntry Demo App and use this code as your app needs. The framework is free and open source, so you can use the framework "as is" or utilize any PowerScript code that you see in your App as you require.

FYI: http://chrispollach.blogspot.com/2024/05/2024r2.html

If your testing the PB 2025 Beta product, then this framework version might also be of interest ..

http://chrispollach.blogspot.com/2024/10/2024r3.html

HTH

Regards .. Chris

Comment
  1. Paweł Kasperek
  2. Monday, 18 November 2024 06:51 AM UTC
Hi Chris,



Thank you for answer. It's very helpful. I checked your example, but I cannot open connection to database. I deployed SQL Serve instance database from your samples, but where I should be change DBConnection params ?

Can you help me?



Regards,

Pawel
  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 18 November 2024 14:41 PM UTC
Hi Pawel;

Yes, the OrderEntry Demo App uses the Appeon PB Demo database. The connection parameters are handled via its OrderEntry INI file. The "SS01" section is used for SS DB connectivity. However, the connection settings are encrypted. So you need to use the INI Admin App provided in the demo app to manage the settings as it will save yours back to the OE INI file encrypted.

FYI: https://chrispollach.blogspot.com/2024/06/adminini.html

HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
Mark Goldsmith Accepted Answer Pending Moderation
  1. Thursday, 14 November 2024 15:19 PM UTC
  2. PowerBuilder
  3. # 2

Hi Pawel,

Take a look at the VerticalScrollPosition property of the DataWindow object. Changing this value will allow you to move the scroll bar down thus showing the column you would like to see. You may have to play with the value to get to where you want it to be (and should you redesign the layout this value will likely need to change).

You can make this more dynamic, utilizing the VerticalScrollMaximum property and the Y value of each column, which is my preferred way, but you could just identify the value that will take you to this column and hardcode it.

HTH...regards,

Mark

Comment
There are no comments made yet.
Paweł Kasperek Accepted Answer Pending Moderation
  1. Thursday, 14 November 2024 12:16 PM UTC
  2. PowerBuilder
  3. # 3

Hi,

Thank you for your answers, but my problem is more complicated. I've got one row with multiple columns. I designed DW vertically.

So, the columns are arranged vertically, one after another, as shown in the attached images. The field with value 1 is at the top of the window, while the one with value 2 (in the second image) is at the bottom. By clicking the 'none' button, I want to move to the column with value 2.

Break it down:

 

  • Columns are arranged vertically in sequence
  • Based on attached images (referenced in the text):
    • Value 1 is positioned at the top of the window
    • Value 2 is positioned at the bottom
  • The desired action is to navigate to the column containing value 2 by clicking a "none" button 

I need not ScrollToRow, but ScrollToColum function.

 

 

 

Regards,

Pawel

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 13 November 2024 14:32 PM UTC
  2. PowerBuilder
  3. # 4

Hi, Pawel -

You do not need to re-position the vertical scroll bar. Instead, tell the DataWindow control which row you want to be able to see via the ScrollToRow() method, and let it determine what scrolling (if any) is needed:

* * * Edited to remove unnecessary SetRow method call. * * *

// Optional: Temporarily suspend re-painting of the DataWindow (this can reduce flicker).
dw_1.SetRedraw(False)

// Make row 723 visible within the DataWindow control and make it the current row.
dw_1.ScrollToRow(723)

// Optional: Highlight row 723.
dw_1.SelectRow(0,False)  // Turns highlighting for ALL rows off.
dw_1.SelectRow(723,True) // Turns highlighting on for row 723.

// Optional: Set the current column to the one that contains the validation error.
dw_1.SetColumn("customer_id") // For example...

// Optional: Re-enable live display of the DataWindow's contents.
dw_1.SetRedraw(True)

Best regards, John

Comment
  1. Miguel Leeuwe
  2. Wednesday, 13 November 2024 15:51 PM UTC
Hi John,

Just a small detail: There's no need to do a SetRow() after having done a ScrollToRow().

regards
  1. Helpful 1
  1. John Fauss
  2. Wednesday, 13 November 2024 22:23 PM UTC
Thank you, Miguel! That's what I get for replying in a hurry. I have edited/corrected the snippet of code.
  1. Helpful 1
  1. Paweł Kasperek
  2. Thursday, 14 November 2024 14:25 PM UTC
Hi,



I added a new response because I may not have explained my problem very well in the first step.



Regards

Pawel
  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.