FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse Autosort disabled when inserting a column in code
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Xbrowse Autosort disabled when inserting a column in code
Posted: Thu Mar 29, 2012 12:57 PM
To All

I have noticed that when I ADD a column ( 2 ) with code the Autosort for that column has been disabled.

I have a first name and last name field in a recordset and I use an Add column ..

Is there a way to turn on the Autosort for this column FWH 1202 ?

Thanks
Rick Lipkin

Code (fw): Select all Collapse
DEFINE DIALOG oWork RESOURCE "WORKBROW" of oWndChild

       REDEFINE xBROWSE oLBX         ;
         RECORDSET oRsRepair         ;
         COLUMNS "RN",               ;
                 "ADDR1",            ;
                 "CITY",             ;
                 "PH",               ;
                 "RT",               ;
                 "STATUS",           ;
                 "TN",               ;
                 "PN",               ;
                 "MN",               ;
                 "MODEL",            ;
                 "SNUM"              ;
         COLSIZES 65,150,85,85,85,85,85,85,120,120,120  ;
         HEADERS "Repair Num",       ;
                 "Address",          ;
                 "City",             ;
                 "Phone",            ;
                 "Request Type",     ;
                 "Status",           ;
                 "Tracking Num",     ;
                 "Pref Tech",        ;
                 "Manufacturer",     ;
                 "Model Number",     ;
                 "Serial Number"     ;
         ID 172 of oWork             ;
         AUTOCOLS LINES AUTOSORT CELL

       // autosort does not seem to work with columns added with code 
      ADD oCol TO oLbx AT 2 DATA {|x| x := _ChkCust(oRsRepair:Fields("lname"):Value,;
                   oRsRepair:Fields("fname"):Value)  } HEADER "Customer Name" size 150
      

       ADD oCol TO oLbx AT 5 DATA {|x| x := _ChkComp(oRsRepair:Fields("cc"):Value) };
                   HEADER "Instructions" size 150

...
...
//-------------------
Static Func _ChkCust( cLast,cFirst )

Local cName

If cFirst = " " .or. empty( cFirst)
   cName := substr(alltrim( cLast )+space(40),1,40)
Else
   cName := substr(alltrim( cLast )+", "+alltrim(cFirst)+space(40),1,40)
Endif

Return(cName)


Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse Autosort disabled when inserting a column in code
Posted: Thu Mar 29, 2012 01:48 PM
We have to add SORT <uOrder> clause to the ADD TO oBrw command.

In your example, please try adding
Code (fw): Select all Collapse
SORT "LNAME,FNAME"

to the ADD TO oBrw command.
Because this is a browse of recordset, the expression oRs:Sort := "LNAME,FNAME" will be used by xbrowse for sorting this column.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Xbrowse Autosort disabled when inserting a column in code
Posted: Thu Mar 29, 2012 03:18 PM

Rao

Thank you .. that did the trick ..

Rick Lipkin

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Xbrowse Autosort disabled when inserting a column in code
Posted: Thu Mar 29, 2012 09:52 PM

Rao

It seems that adding the sort allows the column to sort in Ascending order .. when I click on the heading again the order does not switch to Descending.

Is there a way to be able to switch between the orders when you alternate click on the heading ?

Thanks
Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse Autosort disabled when inserting a column in code
Posted: Thu Mar 29, 2012 10:39 PM
It seems that adding the sort allows the column to sort in Ascending order .. when I click on the heading again the order does not switch to Descending.

It should work.
Please check again.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Xbrowse Autosort disabled when inserting a column in code
Posted: Fri Mar 30, 2012 03:23 PM

Rao

I noticed if I just selected the Sort "LNAME" ( instead of "LNAME,FNAME") everything worked as you suggested!

Thanks
Rick Lipkin

Continue the discussion