FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH 2102: XBrowse:SetMultiSelectCol()
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Sat Mar 13, 2021 07:40 PM
Recently many programmers are preferring to provide multiple selection of rows, by showing the selection by way of checkboxes in a separate column (mostly the first column), in preference to the older way of selecting Marquee style MARQSTYLE_HIGHLROWMS.

However, this requires quite a bit of extra coding by the programmer. Now this is very much simplified.

What all required is to make one call to the new Method SetMultiSelectCol().

Syntax:
Code (fw): Select all Collapse
oBrw:SetMultiSelectCol( [uCol], [lFooter] )


Parameters:
1. [uCol]: Optional. If the method is called without parameters or uCol as nil, xbrowse inserts a new column in the 1st position before all defined columns and makes this is the multiselect column.
If uCol is specified (as column object or column's header/creation ordr), that column is configured as multiselection column.

2. [lFooter]: Optional. Defaults to oBrw:lFooter. If .t., sets footer of the column to display the number of records selected.

This column is available as oBrw:oMultiSelCol.

Toggling selection:
1. Double click of space key in this column toggles selection.
2. When oBrw:lFastEdit is .F., space key always toggles selection.
3. If oBrw:bLDblClick is nil, double click on any column toggles selection, if that column's bLDClickdata also is nil.
4. Ctrl-Click always toggles selection.
5. Shift-Click selects all rows from the last selected row till the current row.

Footers:
If any footers contain conditional aggregates depending on the selected rows, such aggregates are automatically updated in the most optimal way, without any extra code by the programmer.

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

REQUEST DBFCDX

function Main()

   local oDlg, oFont, oBrw

   FWNumFormat( "A", .t. )

   USE CUSTOMER NEW VIA "DBFCDX"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 750,500 PIXEL TRUEPIXEL FONT oFont ;
      TITLE FWVERSION + " : oBrw:SetMultiSelectCol()"

   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE ALIAS() ;
      COLUMNS "FIRST", "CITY", "AGE", "SALARY" ;
      CELL LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :RecSelShowRecNo()
      :bClrStd          := { || { CLR_BLACK, If( oBrw:SelectRow(), 0x88EDFB, CLR_WHITE ) } }
      //
      :Salary:nFooterType := AGGR_SUM
      :Salary:bSumCondition := { || oBrw:SelectRow() }
      :Age:nFooterType := AGGR_AVG
      :Age:bSumCondition := { || oBrw:SelectRow() }
      //
      :SetMultiSelectCol()
      :MakeTotals()
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil


Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Mon Mar 15, 2021 11:42 AM

nice

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: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Mon Mar 15, 2021 10:02 PM

Mr.Rao,

muy bueno, ahora cuando cambias de paginas sigue conservando lo seleccionado ??

Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Mon Mar 15, 2021 10:57 PM

Mr Nages,
when I select some records, can i print them?
Do U remember I noticed this problem last mounth

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 2102: XBrowse:SetMultiSelectCol()
Posted: Tue Mar 16, 2021 07:06 AM
Silvio.Falconi wrote:Mr Nages,
when I select some records, can i print them?
Do U remember I noticed this problem last mounth


Yes.
The problem of single record also is fixed now.
Regards



G. N. Rao.

Hyderabad, India
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Tue Mar 16, 2021 08:57 AM

Mr. RAO

This function support TMySQL and MakeTotal

Best Regards,



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Tue Mar 16, 2021 09:01 AM
richard-service wrote:Mr. RAO

This function support TMySQL and MakeTotal


XBrowse's functionality works the same way for any datasource, whether it is tmysql, dbf, ado, etc.
Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Fri Mar 19, 2021 11:10 AM

Mr. Rao,

I ask again, when paging with pageup / pagedown, is the selection preserved or is it lost?

regards.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Fri Mar 19, 2021 12:59 PM
Ariel wrote:Mr. Rao,

I ask again, when paging with pageup / pagedown, is the selection preserved or is it lost?

regards.

Yes, preserved.
Sorry, I did not see your previous question.
Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Wed Mar 24, 2021 12:46 PM

Mr. Rao,

Continuing with the theme, if you press Page Down / Page Up and you have selected one or more items, the selection is lost.

regards.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Wed Mar 24, 2021 01:09 PM
Ariel wrote:Mr. Rao,


Continuing with the theme, if you press Page Down / Page Up and you have selected one or more items, the selection is lost.

regards.


No.
They are not lost.
Please test after you download FWH2102.
Regards



G. N. Rao.

Hyderabad, India
Posts: 389
Joined: Wed Nov 29, 2006 01:51 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Thu Mar 25, 2021 03:49 PM

Mr. Rao,

Perfect!!! Thanks.

Regards.

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Thu Mar 25, 2021 04:25 PM
Is aSelected() used for the selections in the new way ?

I use this kind of functions many times

Code (fw): Select all Collapse
Function markselected(oBrw4)
      if master->(flock())
        FOR I = 1 TO LEN(oBRW4:aSELECTED) // obrw:aSELECTED is an array containing recnos marked
          master->(dbgoto(oBRW4:aSELECTED[I]))
          replace master->selection with .t.
        next
        master->(dbunlock())
      endif
return NIL
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Sat Mar 27, 2021 05:06 AM
This is a very roundabout way to maintain MASTER->SELECTION field.

We are forced to take the aid of arrays like "aSelected", etc., only when the database does not provide a field to indicate the selection status. When the database itself provides this field, we should use this field directly.

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

REQUEST DBFCDX

function Main()

   local oDlg, oFont, oBrw, oCol

   CreateDBF()

   USE MULSEL SHARED NEW

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 300,450 PIXEL TRUEPIXEL FONT oFont

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE ALIAS() ;
      COLUMNS "SEL", "MONTH" ;
      HEADERS "" ;
      LINES NOBORDER FOOTERS

   WITH OBJECT oBrw
      :nStretchCol   := 2
      WITH OBJECT ( oCol := :aCols[ 1 ] )
         :SetCheck( nil, .t. )
         :nFooterType   := AGGR_COUNT
         :bSumCondition := { || ( oBrw:cAlias )->SEL }
         :bOnChange     := { || oCol:RefreshFooter() }
         :nHeadBmpNo    := { || If( oBrw:nLen == oCol:nCount, 1, 2 ) }
      END
      :MakeTotals()
      //
      :CreateFromCode()
   END

   @ 05, 20 BTNBMP PROMPT "INVERT" + CRLF + "SEL"  SIZE 80,50 PIXEL OF oDlg FLAT ACTION BrwSelect( oBrw, nil )
   @ 05,110 BTNBMP PROMPT "SELECT" + CRLF + "ALL"  SIZE 80,50 PIXEL OF oDlg FLAT ACTION BrwSelect( oBrw, .T. )
   @ 05,200 BTNBMP PROMPT "SELECT" + CRLF + "NONE" SIZE 80,50 PIXEL OF oDlg FLAT ACTION BrwSelect( oBrw, .F. )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

static function BrwSelect( oBrw, lSelect )

   local uBm   := oBrw:BookMark

   Eval( oBrw:bGoTop )
   repeat
      if lSelect == nil
         oBrw:oCol( 1 ):CheckToggle()
      else
         oBrw:oCol( 1 ):VarPut( lSelect )
      endif
   until ( Eval( oBrw:bSkip, 1 ) == 0 )
   oBrw:BookMark  := uBm
   oBrw:Refresh()
   oBrw:SetFocus()

return nil

static function CreateDBF()

   local n

   DBCREATE( "MULSEL", { { "SEL", "L", 1, 0 }, { "MONTH", "C", 10, 0 } }, ;
             "DBFCDX", .T., "MUL" )

   for n := 1 to 12
      APPEND BLANK
      FIELD->SEL     := ( N % 3 ) == 0
      FIELD->MONTH   := NTOCMONTH( n )
   next

   CLOSE MUL

return nil


Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: FWH 2102: XBrowse:SetMultiSelectCol()
Posted: Sat Mar 27, 2021 09:37 AM
Nages,
is there SetMultiSelectCol() method on xbrowse.prg ?

Code (fw): Select all Collapse
  Size: 4,108,800 bytes
   Compiler version: Harbour 3.2.0dev (r1904111533)
   FiveWin  version: FWH 21.02
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.1, Build 7600 

   Time from start: 0 hours 0 mins 0 secs 
   Error occurred at: 27-03-2021, 10:05:37
   Error description: Error BASE/1004  Message not found: TXBROWSE:SETMULTISELECTCOL

Stack Calls
===========
   Called from: .\source\function\HARBOUR.PRG => _CLSSETERROR( 247 )
   Called from: xbrowse.prg => TXBROWSE:SETMULTISELECTCOL( 11509 )
   Called from: test.prg => MAIN( 96 )
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