1. Tracy Lamb
  2. PowerBuilder
  3. Tuesday, 17 May 2022 13:05 PM UTC

Hi all,

I've got a few grid style DW's that I'd like to automatically sort when the user clicks on the column name (label). I'm using PB2021 and the latest PFC.  The dw's inherit from u_dw.  I'm turning on the sort service, but it seems to be ignored.  I'd like to sort on the column without any pop-up windows asking for columns, drag/drop etc.  

In the dw's constructor event:

this.of_SetSort(TRUE)
this.inv_sort.of_SetColumnNameSource(0) // Use the column names for sorting
this.inv_Sort.of_SetColumnHeader( TRUE ) // Sort when user clicks column header
this.inv_Sort.of_SetStyle( 0 ) // PB's Drag/Drop Sort window

This is not my preferred style, though.  Even so, I don't know how to pop-up the drag/drop sort window, either, without a separate menu option (Sort).

Any advice is appreciated.

TIA,
~~~Tracy

 

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 19 May 2022 02:06 AM UTC
  2. PowerBuilder
  3. # Permalink

Edit the DataWindow data object and un-check the "Column Moving" property, then re-try.

The sequence of events leading up to the triggering of the pfc_Clicked event in the Sort service (inv_sort) is different for Grid DW's (where Processing=1). Normally, code in u_dw's Clicked event triggers the pfc_Clicked event in inv_Sort... Look at the last six lines in pfc_u_dw's Clicked event. However, this does NOT occur when the Data Object is a grid style.

For grids, the pfc_Clicked event in inv_Sort gets postponed until the pfc_PostLButtonUp event, an event posted from the LButtonUp event. In the pfc_PostLButtonUp event script, the Data Object's style is again checked... If it's a Grid, the pfc_Clicked event in inv_Sort is triggered, but ONLY if the DW's internal syntax has not been modified. DW syntax modification occurs at the proverbial click of a mouse button when Column Moving is enabled. If you disable this property, the DW syntax does not get modified so flippantly. 

really dislike the way u_dw/pfc_u_dw handles the mouse button up/down and clicked events. Frankly, it's a hot mess. I'm not sure why it's this way, but I suspect someone made one or more changes without thoroughly understanding everything.

If your app needs to let the user move columns around in a grid DW, use the DW Grid service to accomplish this.

Comment
  1. Tracy Lamb
  2. Thursday, 19 May 2022 13:31 PM UTC
Thank you John... excellent research! I don't think I would have found this on my own. In my u_dw object, I was over-riding the lbuttonup, lbuttondown, rbuttonup, and rbuttondown events to prevent the default windows RMB menu from popping up after my own rbuttonup RMB menu. (Explained to me in another question I posted.) I never use the lbuttonup, lbuttondown and rbuttondown events. So I removed the over-ride on those events and just left the over-ride in the rbuttonup event. Everything seems to work fine now.

Many thanks,

~~~Tracy
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 17 May 2022 13:24 PM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy,

Your code seems to be OK.

In your datawindow the names of header texts must be the same as column names with suffix "_t" (by default, see instance variable is_defaultheadersuffix of the service; changeable with of_SetDefaultHeaderSuffix).

Also you must not overwrite the clicked event of the datawindow control.

Check with debugger the pfc_clicked event of the sort service. If it doesn't stop something is wrong with inheritance. If it stops you can debug and see what's going wrong.

HTH,

René

 

Comment
  1. Tracy Lamb
  2. Tuesday, 17 May 2022 23:25 PM UTC
My column headers are all correct ... column name + "_t". I do not overwrite the clicked event. I put a break point in the sort service's pfc_clicked event.. it's not firing. I'm at a loss. In PB2019, PFC 5 this worked fine. In PB2021 I decided to upgrade to the latest PFC, that's the only thing that's changed.

  1. Helpful
  1. John Fauss
  2. Wednesday, 18 May 2022 01:41 AM UTC
Are you tracing pfc_clicked in n_cst_dwsrv_sort or in pfc_n_cst_dwsrv_sort? The action is performed in pfc_n_cst_dwsrv_sort. Also, call the of_GetColumnHeader() returns Boolean function in the Sort service to ensure it returns True.
  1. Helpful
  1. René Ullrich
  2. Wednesday, 18 May 2022 05:03 AM UTC
The pfc_clicked event is triggered from datawindows clicked event (in pfc_u_dw). Try to start debugging there.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 17 May 2022 13:40 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Tracy - 

You said: "I don't know how to pop-up the drag/drop sort window, either, without a separate menu option (Sort)."

There is an existing "Sort..." menu item in menu object m_master (under the View menu header). This menu item invokes the pfc_SortDlg() event in u_dw to display the Sort dialog window.

If you don't want to use this means of displaying the Sort dialog window, invoke u_dw's pfc_SortDlg() event by some other means.

Regards, John

Comment
  1. Tracy Lamb
  2. Tuesday, 17 May 2022 23:28 PM UTC
I added a "Sort List" option to the RMB menu on the dw... this works fine. I'm just trying to figure out why I can't click on a column header to sort the list.
  1. Helpful
There are no comments made yet.
Arthur Hefti Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 04:19 AM UTC
  2. PowerBuilder
  3. # 3

Hi

did you check if the labels are enabled, i.e have "Enabled" checked.

Regards
Arthur

Comment
  1. Tracy Lamb
  2. Wednesday, 18 May 2022 12:07 PM UTC
Yes, all columns labels are enabled.
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 05:29 AM UTC
  2. PowerBuilder
  3. # 4

Tracy,

1.  Every column name, that need sorting, should be in a predefined style, eg. if the column name is address then column heading should be address_t.
2.  Then in the clicked event, write the following code.

String ls_name

SetRedraw(False)
If dwo.Type = "text" Then
	ls_name = dwo.Name
	ls_name = Left(ls_name, Len(ls_name) - 2)
	search_col_name = ls_name
	
	Choose Case Mid(Describe(ls_name + ".coltype"),1,5)
		Case 'char('
			This.SetSort(ls_name + " A")
		Case 'datet'
			This.Setsort(String(ls_name, 'yyyy/mm/dd') + " A")
		Case 'long'
			This.Setsort(ls_name + " A")
	End Choose
	This.Sort()
End If
SetRedraw(True)

HTH

Happiness Always
BKR Sivaprakash

Comment
  1. Tracy Lamb
  2. Wednesday, 18 May 2022 12:06 PM UTC
I'm trying to use the PFC Sort service... it works fine in my last version, PB2019 and PFC5. I'm upgrading everything to PB2021/PFC 12.5.

  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 09:39 AM UTC
  2. PowerBuilder
  3. # 5

Hi,

Like Arthur already said: make sure the column labels in the header are ENABLED.

Another thing you might want to look for, is if there are any OVERRIDEs in some scripts.

 

regards.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 15:54 PM UTC
  2. PowerBuilder
  3. # 6

Forgive me if I'm asking the obvious, but is the DataWindow control in question a PFC u_dw user object?

Would you be willing to export (1) the DW data object and (2) the window, zip the exported source files and attach the zip file to a new response so that I and/or others can examine them?

Comment
  1. Tracy Lamb
  2. Wednesday, 18 May 2022 17:59 PM UTC
Yes, the DW control is a descendant of u_dw. I'll post the zip file in a response.

  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 18 May 2022 18:05 PM UTC
  2. PowerBuilder
  3. # 7

Attached is a zip file with the info requested earlier.

I have a utab_folder object, inherited from u_tab. 

A utab_customer inherited from utab_folder. 

On utab_folder, there are 4 tabs, on tab 2 there is 1 dw, dw_2 inherited from u_dw.  

In utab_customer, the data object is set to d_customer_equipment.

The utab_customer object is contained in w_folder_customer.

All 4 objects are in the attached zip file...

Attachments (1)
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.