1. Tracy Lamb
  2. PowerBuilder
  3. Friday, 20 May 2022 02:56 AM UTC

Hi all,

Took me a few days to get the Column sort to work, but it's working great now.  I have a question: I have a few master/detail windows.  When I click on a column label in the master dw to sort by that column, it sorts fine, but the detail dw automatically updates to whatever it should be for row 1 of the master dw, even though the selected row hasn't changed.  So, sorting on the column seems to trigger the linkage service, but always with row 1.

I also have a Sort button on the Toolbar that calls of_SendMessage ("pfc_sortdlg") . This displays a PB drag/drop window for sorting on multiple columns. Same behavior with the detail dw.

PB2021/PFC 12.5 . Any thoughts would be appreciated.

~~~Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 17:16 PM UTC
  2. PowerBuilder
  3. # Permalink

Thank you all for your feedback.  I found an easy way to accomplish the update of details when the sort order changes.  Works with column sorting, PB Drag/Drop sort, and filtering.

In the udw_master control,  pfc_RowChanged event:

//Force reselect of detail rows
long ll_SelectedRow

ll_SelectedRow = this.GetSelectedRow(0)

if ll_SelectedRow > 0 then
   this.SetRow(ll_SelectedRow)
else
   this.SetRow(1)
   this.SelectRow(1, TRUE)
end if

I put the ELSE in there just in case the user applies a filter that eliminates the currently selected row.

~~~Tracy

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 13:52 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Tracy - 

In all likelihood, somewhere, a dw.SetRow(1) method is being called.

Please be aware that the current row and the selected (highlighted) row can be different, because you can have more than one row selected, but only one row can be current - so the two don't always correlate.

With that in mind, you want to follow the code; If you examine the code in DW sort service (pfc_n_cst_dwsrv_sort), you'll see in both the pfc_Clicked (triggered when you click on a column heading) and the pfc_SortDlg (when you use the Sort dialog window) events call the of_Sort() object function in the sort service object to actually sort the rows in the DW.

In the of_Sort function, it invokes the Sort method in the DW, but it also subsequently triggers the pfc_RowChanged event in the DW. In pfc_u_dw's pfc_RowChanged event, you'll see where it triggers the pfc_RowChanged event in the Linkage service when linkage is being used, as it is in your case. In that event script, the pfc_RowFocusChanged event in the linkage service is triggered and the row number argument value passed in is the result of a DW.GetRow() call. This refreshes any detail/child DW's. Whew!

If in your case, since the detail DW is being refreshed to display the detail info linked to master DW row 1, then somewhere along the way the current row in the master DW is being set to row 1. I suggest using the debugger and setting a break point in pfc_u_dw's RowFocusChanging event... you'll get stopped there a few times along the way, but eventually, when the newrow argument value to this event comes in as 1, the call stack should tell you where the SetRow method is getting called from.

HTH, John

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 13:58 PM UTC
  2. PowerBuilder
  3. # 2

You are correct, this is a ....feature.... of the PFC Sorting/Linkage services.

One way to handle this is:

 

// Clicked event of the DW
// ---------------------------------
w_window.SetReDraw (FALSE)

IF (lb_reset_row AND il_save_current_row > 0) THEN

   ll_rc = this.SetRow (il_save_current_row)  
   ll_rc = ScrollToRow (il_save_current_row)
   il_save_current_row = 0

   w_window.SetReDraw (TRUE)

ELSE
   il_save_current_row = dw_1.GetCurrentRow ()

   ll_rc = this.SetSort (ls_cmd)
   ll_rc = this.Sort ()

   lb_reset_row = TRUE
   this.EVENT POST clicked (ll_row_zero)

END IF

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