FWH 2103: XBrowse: oSortCbx

FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Wed Apr 14, 2021 5: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: Select all  Expand view

// 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: Select all  Expand view

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: Select all  Expand view
#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
 


Image
Regards

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

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » Thu Apr 15, 2021 7:23 am

marvelous
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Thu Apr 15, 2021 12:55 pm

Silvio.Falconi wrote:marvelous

Made for You :)
Regards

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

Re: FWH 2103: XBrowse: oSortCbx

Postby Marc Venken » Thu Apr 15, 2021 2: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1426
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » 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: Select all  Expand view


#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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Tue Jun 01, 2021 12:56 pm

Test with TDatabase
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » Tue Jun 01, 2021 8:50 pm

nageswaragunupudi wrote:Test with TDatabase
Code: Select all  Expand view
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: Select all  Expand view
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

Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Wed Jun 02, 2021 2:39 am

Please test this
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » Wed Jun 02, 2021 6: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Wed Jun 02, 2021 6: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » Wed Jun 02, 2021 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: FWH 2103: XBrowse: oSortCbx

Postby TimStone » Wed Jun 02, 2021 6: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: Select all  Expand view
  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: Select all  Expand view
    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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FWH 2103: XBrowse: oSortCbx

Postby nageswaragunupudi » Wed Jun 02, 2021 6: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 2103: XBrowse: oSortCbx

Postby Silvio.Falconi » Mon Jun 07, 2021 9:11 pm

thanks rao

Image

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: Select all  Expand view
{ "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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests