Force a POST sort on xBrowse

Force a POST sort on xBrowse

Postby Rick Lipkin » Mon Jun 07, 2021 2:53 pm

To All

I have an Encrypted Sql table with a field called "EmployeeName .. Select * From Rates order on EMployeeName .....

That is fairly straight forward, but the Field "EmployeeName" is Encrypted .. To Unencrypt the EMployeeName Column I use the old Trick Add oCol ( see below ) and Have a user defined function that Dencrypts the EmployeeName field .. so when a user call the program .. all they see is the un-encrypted EMployeeName.. ( great )

However, when the table was opened it was ordered with the encrypted EmployeeName values ... which once xBrowse is created now has the un-encrypted EMployeeName out of senquence with the encrypted table value ..

Is there a way to re-sort the EMployeeNAme column on its dencrypted value ?.. after xprowse has been painted with the encrypted value ? .. The Sort:EmployeeName ( now de-encrypted) does nothing ...

Any Ideas ?

Thanks
Rick Lipkin




Code: Select all  Expand view


cSql := "Select * From [Rates] "
cSql += "Order by [EmployeeName]"

TRY
   oRsRate:Open( cSQL,xCONNECT )
CATCH oErr
   MsgInfo( "Error in Opening RATES table" )
   RETURN(.F.)
END TRY

.....
.....

REDEFINE xBROWSE oLBX             ;
       RECORDSET oRsRate                 ;
       COLUMNS "EFFECTIVEDATE",          ;
               "EMPLOYEERATE",           ;
               "ACTIVE"                  ;
       COLSIZES 80,80,65                 ;
       HEADERS "Effective Dt",           ;
               "Rate",                   ;
               "Active"                  ;
       ID 111 of oDlg                    ;
       AUTOSORT AUTOCOLS LINES CELL

   oLbx:nMarqueeStyle := MARQSTYLE_HIGHLROW
   oLbx:lRecordSelector := .f.
   oLbx:lHScroll := .f. // turn off horiz scroll bar

   ADD oCol to oLbx AT 1 DATA {|x| x := _ChkUser(oRsRate:Fields("EmployeeName"):Value) }   HEADER "Employee Name" size 200  ;
                         Sort:EmployeeName


//--------------------------------
Static Func _ChkUser( cEmployeeName )

Local cName

cEmployeeName := alltrim(dencrypt(cEmployeeName ))

cName := substr( cEmployeeName+space(36),1,36)

Return( cName )

 



Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Force a POST sort on xBrowse

Postby nageswaragunupudi » Tue Jun 08, 2021 12:29 am

If this is only a readonly browse, please read the data into an array with
Code: Select all  Expand view
aData := oRs:GetRows( {colnames} )

Then decrypt and browse the array
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Force a POST sort on xBrowse

Postby Rick Lipkin » Fri Jun 11, 2021 2:28 pm

Rao

It appears the sort order is based on the original encrypted data ... When I build the browse I am de-encrypting it on the fly ..

Code: Select all  Expand view

 ADD oCol1 to oLbx AT 1 DATA {|x| x := _ChkUser(oRsEmp:Fields("UserID"):Value) }   HEADER "UserId" size 85 ;
                              SORT "UserID"
   ADD oCol2 to oLbx AT 2 DATA {|x| x := _ChkCust(oRsEmp:Fields("FullName"):Value) } HEADER "Staff Name" size 150 ;
                              SORT "LNAME"
 


When I click on the USER ID Column header .. it does not sort properly based on the cell data .. it appears to sort on the original encrypted table data

Code: Select all  Expand view

"Select * From [Staff] Order by UserId" // where user id is encrypted
 


Any thoughts on how to sort ( or resort ) the ( de-encrypted cell ) UserID column so it will display properly .. apparently the sort is being controlled by the way the table was opened in its original encrypted format ..

Thanks
Rick Lipkin


Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Force a POST sort on xBrowse

Postby James Bott » Fri Jun 11, 2021 4:38 pm

Rick,

How about de-encrypting into an array, then browsing the array.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Force a POST sort on xBrowse

Postby Rick Lipkin » Fri Jun 11, 2021 6:15 pm

James

Rao made the same suggestion .. however, I do not want to de-encrypt and copy an entire table to an array or temp table .. because now I compound how many places I have to write updates .. If I add\edit or Delete a record .. I have to update a row or rows in the array and then write the same information back to the Sql Table .. gets really messy.

I was hoping for a simpler solution and the sort is just cosmetic .. however, the legacy application is sorted by Name and I would like to maintain the same look an feel .. was hoping for a simpler solution .. I was hoping the arrow column sort would sort the data you see in the browse.

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Force a POST sort on xBrowse

Postby Rick Lipkin » Fri Jun 11, 2021 7:31 pm

Rao

Just a quick thought .. could you create a new xBrowse method oLbx:Sort("Column Name" ) ???

Usage Like
ON PAINT ( oLbx:Sort("EmployeeName"),oLbx:ReFresh() )

Thanks

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests