FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH 2103: XBrowse: oSortCbx
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

FWH 2103: XBrowse: oSortCbx

Posted: Wed Apr 14, 2021 05:04 AM
We are aware that the user can change the sort order of columns by clicking on the header in autosort mode.

There are many programmers who like to provide a combobox to change the sort order additionally. In this case, programmers are often facing difficulty in perfectly synchronizing the combobox and the built-in sort by clicking the header.

This process is extremely simplified by introducing oBrw:oSortCbx and internally managing the combobox.

There are two ways of creating:
Method-1: Recommended
Code (fw): Select all Collapse
// after creating the browse and calling oBrw:CreatefromCode()
@ r,c COMBOBOX oBrw:oComboCbx VAR oBrwL:cSortOrder SIZE w,h PIXEL OF oDlg/oWnd/oBar


Rest is fully taken care of by the XBrowse.

Method-2: This method also works
Code (fw): Select all Collapse
local cOrder := ""

@ r,c COMBOBOX oCbx VAR cOrder SIZE w,h PIXEL OF oDlg/oWnd/oBar

@ r,c XBROWSE oBrw ........... DATASOURCE <src> .........
...
oBrw:oSortCbx := oCbx
oBrw:CreateFromCode()


This is a sample program:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oDlg, oBrw

   USE CUSTOMER NEW VIA "DBFCDX"
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE ALIAS() AUTOCOLS AUTOSORT ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   @ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return nil


Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Thu Apr 15, 2021 07:23 AM
marvelous
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Thu Apr 15, 2021 12:55 PM
Silvio.Falconi wrote:marvelous

Made for You :-)
Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Thu Apr 15, 2021 02:55 PM

Very Nice and helpfull. I was in the progress of integrating this.

A pending request (but not that high on a todo list) could be to select colums in one process.

I see in the sample above that you have to click 4 times on the header and select 4 times the column to unselect for the browse.
My idea by this :

I open the browse with all columns. select the ones that I need to process and save the state of the browse.
Next time I open just one of the created browses statusses and I have the browse that I want.
So a load and save state would be SUPER ))

This would in my case eliminated the need to program folders where I mostly group different items from the same database (basic data, digital media, values, ...)

Maybe a postion on the TODO list.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Tue Jun 01, 2021 10:01 AM
nageswaragunupudi wrote:
Silvio.Falconi wrote:marvelous

Made for You :-)


Nages,
as I wrote you I tried it with Tdatabase and I not see any data on combobox

Code (fw): Select all Collapse
#include "fivewin.ch"

 REQUEST DBFCDX


function Main()

   local aData

   FERASE( "CUSTOMER.CDX" )
   USE CUSTOMER NEW EXCLUSIVE VIA "DBFCDX"
   aData := FW_DbfToArray( "FIRST,LAST,STREET", , { || RECNO() < 11 } )
   GO TOP
   FW_CdxCreate()
   CLOSE CUSTOMER

 
      UsageTdatabase()

return nil
//-----------------------------------------------------------------------------------//

 function UsageTdatabase()

   local oDlg, oBrw
   local oClienti
   local oGet
   local cSeek:=space(100)

   oCustomer:= TCustomer():New()

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE


    @ 10, 165 GET oGet VAR cSeek SIZE 280,24 PIXEL OF oDlg


   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oCustomer AUTOCOLS AUTOSORT ;
      NOBORDER LINES

   WITH OBJECT oBrw
     :lIncrFilter   := .t.
     :oSeek         := oGet

      :CreateFromCode()
   END

   @ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

   CLOSE DATA

   return nil
//-----------------------------------------------------------------------------------//
CLASS TXData from TDataBase
     DATA cDbfPath init  cFilePath(GetModuleFileName( GetInstance() ))
     DATA cExePath init  cFilePath(GetModuleFileName( GetInstance() ))
  ENDCLASS

  CLASS TCustomer from TXData
   METHOD New()
ENDCLASS

METHOD New( lShared ) CLASS TCustomer
   Default lShared := .t.
   ::super:New(,::cDbfPath + "Customer" ,, lShared)
   if ::use()
      ::setOrder(1)
      ::gotop()
   endif
   RETURN Self
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Tue Jun 01, 2021 11:15 AM

oSortCbx is for sorting columns.
Works with DBF, TDatabase, ADO and others.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Tue Jun 01, 2021 12:56 PM
Test with TDatabase
Code (fw): Select all Collapse
function TestTDatabase()

   local oDlg, oBrw, oDbf

   oDbf  := TDatabase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
   oDbf:SetOrder( "FIRST" )
   oDbf:GoTop()

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oDbf AUTOCOLS ;
      AUTOSORT ;
      NOBORDER CELL LINES

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   @ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

   oDbf:Close()

return nil

This is working as expected
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Tue Jun 01, 2021 08:50 PM
nageswaragunupudi wrote:Test with TDatabase
Code (fw): Select all Collapse
function TestTDatabase()

   local oDlg, oBrw, oDbf

   oDbf  := TDatabase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
   oDbf:SetOrder( "FIRST" )
   oDbf:GoTop()

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oDbf AUTOCOLS ;
      AUTOSORT ;
      NOBORDER CELL LINES

   WITH OBJECT oBrw
      :CreateFromCode()
   END

   @ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

   oDbf:Close()

return nil

This is working as expected




sorry, i beg your pardon i am mortified, it was my mistake i forgot a comma and everything was not working!!!!

because I have my dbf config

Code (fw): Select all Collapse
local aCols    := { ;
                { "CliCognome"     , "Cognome",,        120},;
                { "CliNome"        , "Nome"   ,,        120 },;
                { "CliFiscale"     , "Codice Fiscale",, 100 },;
                { "CliPartiva"     , "Partita Iva",,    110 },;
                { "CliIndiriz"     , "Indirizzo",,      120 },;
                { "CliPaese"       , "Località",,       120 },;
                { "CliCap"         , "Cap", ,            60 },;
                { "CliProv"        , "Provincia",,       40 },;
                { "CliRegione"     , "Regione", ,        90 },;
                { "CliTelef1"      , "Cellulare",,      100 },;
                { "CliTelef2"      , "Telefono",,       100 },;
                { "CliEmail"       , "Email", ,         140 },;
                { "CliSitoWeb"     , "Sito Web",,       140 },;
                { "CliAppunti"     , "Appunti", ,       200 }}


I had put a single comma for each line
sorry again
Now all is worKing with Tdatabase



I make a test "all together" ( csortbox, search,multisel)

even if tonight working and trying to find a customer I realized that it does not refresh the index on which to search that is

if I initially look for the name "Angelo" and place the combobox in the "Name" column,

it looks for me all the records that have the "Name" = "Angelo" field.

Then if I change the combobox item and decide to search on another column,

for example "Location", the procedure rests to search for the cseek again on the "Name" column

I tried to add the change ast the combobox

@ 10,20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg ;
ON CHANGE ( oBrw:Seek( "" ), ;
oBrw:cFilterFld := oBrw:oCol( oBrw:cSortOrder ):cExpr, ;
oBrw:SetFocus() )

It run but I wish Know if this is right for you, thanks

at last , When we select a column of xbrowse ( Autosort) it refresh also the combobox but not refresh the index need for the search, which remains the previous one

How resolve this ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 02:39 AM
Please test this
Code (fw): Select all Collapse
function TestTDatabase()

   local oDlg, oBrw, oDbf

   oDbf  := TDatabase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
   oDbf:SetOrder( "FIRST" )
   oDbf:GoTop()

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL TRUEPIXEL RESIZABLE

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oDbf AUTOCOLS ;
      AUTOSORT ;
      NOBORDER CELL LINES

   WITH OBJECT oBrw
      :lIncrFilter   := .t.
      :bOnSort       := { |b,oCol| oBrw:Seek( "" ), ;
                             oBrw:cFilterFld := oCol:cExpr, ;
                             oBrw:SetFocus() }
      //
      :CreateFromCode()
   END

   @ 10, 20 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder SIZE 100,400 PIXEL OF oDlg
   @ 10,140 SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE 200,24 PIXEL OF oDlg COLOR CLR_HRED,CLR_YELLOW

   ACTIVATE DIALOG oDlg CENTERED

   oDbf:Close()

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 06:36 AM

thanks Rao
do have have a ssmple to put combobox and srarch on topbar of xbrowse?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 06:59 AM

I suggest you do not use topbar unless it is no other way
To the extent possible, put all your controls on the dialog only.

Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 08:41 AM
nageswaragunupudi wrote:I suggest you do not use topbar unless it is no other way
To the extent possible, put all your controls on the dialog only.


ok thanks
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 06:08 PM
Following your examples, I wanted to show a box on the dialog to provide feedback for the keys typed, and to allow the selection of the column. I use resources, so I added this:

in Program
Code (fw): Select all Collapse
   REDEFINE SAY oLBxin:oSeek PROMPT oLBxin:cSeek ID 8001 OF oDiw 
   REDEFINE COMBOBOX oLBxin:oSortCbx VAR oLBxin:cSortOrder ID 8002 OF oDiw


In Resource
Code (fw): Select all Collapse
     LTEXT                      "",8001,50,150,165,13
    COMBOBOX        8002,250,210,100,110,CBS_DROPDOWN | WS_BORDER | WS_VSCROLL | WS_TABSTOP


1) I want the SAY to reflect the letters as they are typed. Perhaps a GET would be better ?
2) My field names do not match Headers. So if i want to display the Header list in my combobox, what would be the command ?

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Wed Jun 02, 2021 06:34 PM

REDEFINE SAY oLBxin:oSeek PROMPT oLBxin:cSeek ID 8001 OF oDiw
REDEFINE COMBOBOX oLBxin:oSortCbx VAR oLBxin:cSortOrder ID 8002 OF oDiw


These two lines should be after defining the xbrowse oLbxin.


Also, my field names do not match Headers. So if i want to display the Header list in my combobox, what would be the command ?

You need revised xbrowse.prg
We will send you to your email
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: FWH 2103: XBrowse: oSortCbx

Posted: Mon Jun 07, 2021 09:11 PM
thanks rao



all seem to run ok
i managed to put the search get and combo in the vtaskbar menu and everything works

a question....
I insert these columns on xbrowse

Code (fw): Select all Collapse
 { "CliCognome"     , "Cognome",,        120},;
                { "CliNome"        , "Nome"   ,,        120 },;
                { "CliFiscale"     , "Codice Fiscale",, 100 },;
                { "CliPartiva"     , "Partita Iva",,    110 },;
                { "CliIndiriz"     , "Indirizzo",,      120 },;
                { "CliPaese"       , "Località",,       120 },;
                { "CliCap"         , "Cap", ,            60 },;
                { "CliProv"        , "Provincia",,       40 },;
                { "CliRegione"     , "Regione", ,        90 },;
                { "CliTelef1"      , "Cellulare",,      100 },;
                { "CliTelef2"      , "Telefono",,       100 },;
                { "CliEmail"       , "Email", ,         190 },;
                { "CliSitoWeb"     , "Sito Web",,       140 },;
                { "CliAppunti"     , "Appunti", ,       200 }}



If I wish have on cSortBox only some columns of the xbrowse not all

{ "CliCognome" , "Cognome",, 120},;
{ "CliNome" , "Nome" ,, 120 },;

{ "CliPaese" , "Località",, 120 },;
{ "CliCap" , "Cap", , 60 },;
{ "CliProv" , "Provincia",, 40 },;
{ "CliRegione" , "Regione", , 90 },;


how I can to make only these ?

it's possible ?

that is my head tells me that I have to remove the AUTOSORT command and I have to set every column I want to create the sort but how to do it?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com