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
 
Additional info

If I check the Sort immediately after the Sort Dialog executes, the value stored in dw_master.Object.Datawindow.Table.Sort is '?'

however....the sort worked on the screen.

I think this explains why passing the sort string to my report is not working but am wondering why Object.Datawindow.Table.Sort is not retaining the sort value.

 
Statey,

I'm not too familiar anymore with pfc's but:
1)
did you precede

"dw_master.Object.Datawindow.Table.Sort"

with it's "tab_1.tabpage_3."

when it returned " is '?'"

2)
then also, I don't see anywhere you asign the sort to the
tab_1.tabpage_3.dw_master

3) tip:
use an instance dw like idw_master and assign the tabpage dw to that one and work with the instance variable.

idw_master = tab_1.tabpage_3.dw_master
idw_master.of_SetSort(TRUE)
etc.

hope it helps
Miguel

regards,
Miguel L.
 
another thing:

if the way sort functionality of pfc's is the one that makes your dw sort by the label of a column that you click on ...
remember the name of the label has to be coincidente with the name of the corresponding column:
columnName + '_t'
if not the sort doesn't work.
(i might be wrong and it must be 't_' + columnName instead ....)


regards,
Miguel L.
 
Hi Miguel,

1) Yes - the Tab is referenced when we make the call to
Object.Datawindow.Table.Sort.

I may have abbreviated object names in my original example above.


2) We do not assign the sort - we just call the pfc_sort dialog.

tab_1.tabpage_1.dw_pending_hcbc.Event pfc_sortdlg()

It exeutes the sort and the sort appears to be fine. However, we are trying to get the resulting sort criteria so we can pass it to our print datawindow to sort that with the same criteria. We do this by assiging the sort criteria into a string from the object (as shown below) however, the object is not retaining the sort criteria.
ls_Sort = tab_1.tabpage_3.dw_pending_rede_master.Object.Datawindow.Table.Sort


3) Do you mean to use an instance variable instead of 'THIS'?

thanks


 
3) yes I did but not so much for THIS and since you're referring the dw with full 'path' it should work.

let me migrate some old app I've got that uses pfc's and see if there's something like of_getSort() ...

I'll get back

regards,
Miguel L.
 
As far as the 'column_name_t' goes, we should be all set there. We reviewed it and the names are formatted correctly and match......also, the fact that the sort executes ok seems to confirm.

The only issue is how to get the sort dialog results (aka sort criteria string) from Object.Datawindow.Table.Sort.

Possible clue. this is the only screen that we have with multiple Tabs that use sort/filter but theyeach have their own handling (constructor where sort/filter services are started and sort/filter button click handlers). could they somehow be stepping on eachother? tab_pg1, tab_pg2 and tab_pg3 all execute code to start the sort service as shown below.
maybe these need to be combined so it only executes once - although I tried commenting 2 tabs out....

// 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)


 
tabpages ....

is there not such a property that says that the constructor event will only be executed when tabpage first activates?

tried to put all the code of the constructors in the open event?

got to go but will be back in an hour or so.

good luck.


regards,
Miguel L.
 
no good to simply keep the sort in an instance variable?
right back!


regards,
Miguel L.
 
My debugging shows that all 3 of the tab constructors execute when the screen first opens (and not when the individual tabs are selected). so this means the code to start the sort & filter services executes 3 times.

I am wondering if maybe the Sort and Filter services should be started elsewhere so only it only executes one time but I am not sure where this would be.

I am not sure if the tabs are pfc_tabs. Is there an easy way to tell?

 
re: no good to simply keep the sort in an instance variable?

That is sort of what we are trying to do in our local string but how do we get the sort criteria string from the sort dialog?
 
okay so the problem is not that the constructors have not been executed or that they are executing more than once.

are your tabpages pfc tabpages. You can tell by checking the properties of each tabpage (might be easier to simply export the code), but again, it was just a thought. Your initial sort is working.

Thoughts: (sorry for not being too clear it's late already here)
--------
is your dw sharing data somehow? That might overrule your sort

checking out pfc's (old ones, version 5.x):
------------------------------------------
supposing your datawindows are of type u_dw ...
pfc datawindow u_dw / pfc_dw uses a service:
pfc_n_cst_dwsrv_sort, that has a function:
of_setsort(): assigns sort to message.object
(code at the end)
// Get the return PowerObject.
lnv_return = Message.PowerObjectParm
// Check if the dialog was close via the Cancel button.
IF lnv_return.ii_rc <> 1 Then
Return lnv_return.ii_rc
end if

Return idw_Requestor.SetSort (lnv_return.is_rs)
--------------------------------

as you can see this is working in combination of a Message object. (message.powerobjectparm). Are you doing something with the message object that could interfere?

I would do the next:
-------------------
simply try to put a debug-stop on this previous return and see what value is present in "lnv_return.is_rs" and see where the code execution goes afterwards.

in your datawindow of type u_dw you might be able to obtain the result next way?:
the pfc_n_cst_dwsrv (present in instance variable in u_dw : inv_sort of type n_cst_dwsrv_sort ) has an of_getsort() function.

if nothing works add a function to your pfe layer (if you have): u_dw.of_getsort() (the service has but the u_dw does not have this function).

simply put the lnv_return.is_rs value in an instance string variable and somehow assign it to a variable in your u_dw object, since the service is destroyed all the time.

hope it helps.
Miguel


regards,
Miguel L.
 
RE: is your dw sharing data somehow? That might overrule your sort.

The Tab in question is sharing data.

The following line of code appears in the tab's DW constructor AFTER the Sort & Filter Service start code (mentioned above).

This.ShareData(tab_1.TabPage_3.dw_pending_rede_detail)

This shares the dw data with our detail dw.
 
IMPORTANT CLUE:

I commented out the ShareData() calls and am now able to get the sort criteria from the object
[ tab.tabpg.dw.Object.Datawindow.Table.Sort ]

However, without the ShareData(), our screen is not going to work properly.

any ideas how to implement this while sharing data?

 
more ino...............


I may have jumped the gun.

With ShareData() commented out, I am able to read the sort criteria from the Object.Datawindow.Table.Sort object immediately after the sort dialog executes a sort.

however.....

when the user clicks the print button and then I try to access the sort criteria in the sort object, it is no longer there.

I suppose that I can store it after the sort, but this is not going to provide a way to get the sort criteria if theuser sorts via column headings instead of the sort dialog and I still have not resolved how to implement sort while ShareData() is being used.

I am all ears !!!



 
hello Statey,

we've got a time-diference since I'm in Europe and got to go right now.

obviously the problem is the sharedata: the sort order of the datawindow your sharing with is assigned also to the other one.
You might:
use rowscopy() or something like dw_1.object.data = dw_2.object.data instead of rowscopy, though it is slower.

if no good previous solution, yes you have to save the sort assigned by the dialog.
I'll get back as soon as posible, maybe 2 hours from now.


regards,
Miguel L.
 
before modifying pfc's:
----------------------
you said:
"The Tab in question is sharing data.

The following line of code appears in the tab's DW constructor AFTER the Sort & Filter Service start code (mentioned above).

This.ShareData(tab_1.TabPage_3.dw_pending_rede_detail)

This shares the dw data with our detail dw."
-------------
a solution might be:
After the sort & filter service, you save the sort before sharing the data:

tab_1.tabpage_1.dw_pending_hcbc.Event pfc_sortdlg()
ls_savedSort = tab_1.tabpage_3.dw_pending_rede_master.Object.Datawindow.Table.Sort
This.ShareData(tab_1.TabPage_3.dw_pending_rede_detail)
// now the sort for the detail will be the one of the main dw, so simply assign back the original sort obtained after pfc_sortdlg()
tab_1.tabpage_3.dw_pending_rede_master.setSort( ls_savedSort)
tab_1.tabpage_3.dw_pending_rede_master.sort()
// since the way you share the dw's makes the detail dw to be the secondary one, changes to it won't affect to the main dw.

(I hope I'm right)



regards,
Miguel L.
 
RE: a solution might be: After the sort & filter service, you save the sort before sharing the data.

No, that doesn't work. The reason is that the Sort Criteria does NOT get set until the user either clicks the sort button (which launches the Sort Dialog) or clicks on a Column header. so there is no point to copy the Sort Criteria from the object until after either of these occurs. the ShareData() call is in the constructor. Originally, we did not try to get the Sort Criteria until the user clicked on the Print button to print the grid data - like our other screen that don't use ShareData(). However, this is where we ran into the issue of the Sort object not having the Sort data. As mentioned above, I added code to copy from the sort object into an instance variable after the Sort Dialog (in our Sort button handler) and this works fine, but I also need to get the Sort Criteria right after the user Sorts via Column header click and I don't know how to do this.

Is there an event available to catch a column sort?

 
I suppose your dw's are inhereted somehow from pfc_dw (using pfe-libraries). In my case I'm using a 'u_dw'. This where you can add code to save the sort applied by clicking on a header/ sort label. If no inheritance, you can add the functionality straight to pfc_... but normally this is not advisable since you might want to migrate to a higher version of pfc's in the future. (though I really doubt there'll be any newer versions, since you're already working with pb 11 and no newer versions are expected).

pfc_u_dw.clicked event has the following code:
---------------------------------------------
// 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
---
pfc_clicked event of inv_sort (of type n_cst_dwsrv_sort, inherited from pfc_n_dwsrv_sort):
calls:
------
li_rc = of_SetSort (ls_sortstring)
--

the pfc_n_dwsrv_sort has a function called of_getSort():
simply declare an instance variable in your u_dw and add the folowing code to your u_dw.clicked event:
-------------------------------------------------------
// save the sort in variable "is_sort"
IF IsValid (inv_Sort) THEN
is_sort = inv_Sort.of_GetSort()
END IF


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



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

Part and Inventory Search

Sponsor

Back
Top