Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Dialog does not remember previous Sort

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
PB 11.0

We have Sorting and Filtering enabled for a datawindow via the following (in the constructor)

// SORT
THIS.of_SetSort(TRUE) // SET SERVICE ON
THIS.inv_sort.of_SetExclude(ls_sort_exclude) // EXCLUDE items from the DropDown List
THIS.inv_sort.of_SetColumnHeader(TRUE) // USE COLUMN HEADINGS
THIS.inv_sort.of_SetColumnDisplayNameStyle(2) // USE HEADER NAMES
THIS.inv_sort.of_SetStyle(3) // USE SIMPLE SORT BOX
THIS.inv_sort.of_SetVisibleOnly(TRUE) // SET ON
THIS.inv_sort.of_SetUseDisplay(TRUE) // USE DISPLAY COLUMN FOR CLICK SORT

// FILTER
THIS.of_SetFilter(TRUE) // SET SERVICE ON
THIS.inv_filter.of_SetExclude(ls_filter_exclude) // EXCLUDE items from the DropDown List
THIS.inv_filter.of_SetColumnDisplayNameStyle(2) // USE HEADER NAMES
THIS.inv_filter.of_SetStyle(2) // USE SIMPLE FILTER BOX
THIS.inv_filter.of_SetVisibleOnly(TRUE)

The Sort and Filter dialogs are launched via pfc_sortdlg() and pfc_filterdlg() when appropriate buttons are clicked.
The Sort dialog functions as expected and produces correct sorted results. However, if I click on the sort button again, when the Sort Dialog comes up, it does NOT display the previous Sort criteria and sorting of our report does not work.
On our other screens, the Sort Dialog always displays the previous sort (in the same window instance) and it does not exhibit sort issues with the report.

Below is the code where the sort is applied to the report.

//----------------------------------------------
String ls_Sort , ls_Filter

ls_Sort = tab_1.tabpage_3.dw_master.Object.Datawindow.Table.Sort
ls_Filter = tab_1.tabpage_3.dw_master.Object.Datawindow.Table.Filter
n_ds lds_grid_print
lds_grid_print = Create n_ds
lds_grid_print.DataObject = 'd_sq_tb_pend_open_gr'
lds_grid_print.of_SetTransObject(SQLCA)

lds_grid_print.Retrieve()

//Set filter rules
lds_grid_print.SetFilter(ls_filter)

//Set SORT rules
lds_grid_print.SetSort(ls_sort)

//Make Filter
lds_grid_print.Filter()
//Make Sort
lds_grid_print.Sort()
//Print
lds_grid_print.Print()

//Clean House
Destroy lds_grid_print
//----------------------------------------------

It seems like the Sort data is not being maintained and I cannot figure out why. Is there somewhere that I need to store the sort criteria or a checkbox to enable this?

I appreciate any comments/suggestions.

Thanks
 
add the same code to the u_dw.pfc_sortdlg() event:

// save the sort in variable "is_sort"
IF IsValid (inv_Sort) THEN
is_sort = inv_Sort.of_GetSort()
END IF

Happy NewYear!

regards,
Miguel L.
 
Miguel,
I will not be able to modify the code for the pfc sort dailog objects. These are shared with other developers on various projects. I guess we will have to figure something else out.

RE: shouldn't we be shopping and preparing new-years party already?) ;)

Isn't it already next year over there in eurpoe? :)
 
okay then simply add the code to the events of the dw-control (for example the dw control in your tabpage)
wherever needed.
I'll still work, except that the instance variable wouldn't be declared in the u_dw / pfc_u_dw object.

Even better, inherit your own object from u_dw, declare the is_sort variable and add the code to the clicked and pfc_sortdlg events. Then export the code of your window with tab tabpages and dw and change u_dw with your_u_dw objetct. Import back into library.

RE: shopping ... almost, like 14 hours left. Cheers!

regards,
Miguel L.
 
RE: simply add the code to the events of the dw-control

I don't think this will work....unless there is an event for Sort (via column click). The click event for the dw does not indicate a column sort.

What event are you referring to?


 
The click event for the dw does not indicate a column sort."

your datawindow should be inherited someway from pfc_u_dw object. ....
If it is, when you drill down the ancestors of the clicked event you'll see a code like this:

//////////////////////////////////////////////////////////////////////////////
//
// Event: Clicked
//
// Description: Send clicked notification to services
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

// Check arguments
IF IsNull(xpos) or IsNull(ypos) or IsNull(row) or IsNull(dwo) THEN
Return
END IF

// Notify the RowSelect service that the row has been clicked.
IF IsValid (inv_RowSelect) THEN
inv_RowSelect.Event pfc_clicked ( xpos, ypos, row, dwo )
END IF

// Sort services.
IF IsValid (inv_Sort) THEN
// Notify the Sort service, since it may have a request
// to sort on column header.
inv_Sort.Event pfc_clicked ( xpos, ypos, row, dwo )
END IF



/////////////////7/////////////
the code that matters is the call to
inv_sort.event pfc_clicked( ...... )

that's where the sorting takes place.

Miguel


regards,
Miguel L.
 
Miguel,

I am not allowed to modify PowerBuilder internal code (for the pfc_dialog, etc) because that could impace other users on other projects. It seems to me that this might be a bug in PowerBuilder.

I have submitted a case to Sybase in hopes that they might be able to shed some light on why the Sort service/object is not behaving as expected when ShareData() is used. If I ever hear back from them, I will post a follow-up. Otherwise, we are investigating possible workarounds.

I really appreciate you assistance and patience.

- Bill
 
Statey,

I'm not saying you should modify pfc code. What I'm saying is that you can add the code to the clicked event of your datawindow control in your window.


regards,
Miguel L.
 
RE: you can add the code to the clicked event of your datawindow control

I tried that.
The sort object does not return the sort criteria at this point. It's the original issue - the object loses the info after the Sort Dialog is closed. this only happens when ShareData() has been invoked and it must be a bug with the sort service.


 
Okay, sorry ... the problem is that you share the data in the constructor event.

So ... simple solutions:
- don't use sharedata (use rowscopy instead) / don't use sharedata in the constructor event.
- instead of passing your secondary shared detail datawindow to the sort service, use the primary (if the re-sorting is not a problem), the secondairy shared dw will automatically adopt the sort applied.

If you want, export your window and if necesairy controls and paste the code. I'll take a look at it.


regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top