FWH 2102: XBrowse:SetMultiSelectCol()

FWH 2102: XBrowse:SetMultiSelectCol()

Postby nageswaragunupudi » Sat Mar 13, 2021 7: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: Select all  Expand view
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: Select all  Expand view

#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
 


Image
Regards

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Silvio.Falconi » Mon Mar 15, 2021 11:42 am

nice
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 2102: XBrowse:SetMultiSelectCol()

Postby Ariel » Mon Mar 15, 2021 10:02 pm

Mr.Rao,

muy bueno, ahora cuando cambias de paginas sigue conservando lo seleccionado ??
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Silvio.Falconi » 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 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 2102: XBrowse:SetMultiSelectCol()

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby richard-service » Tue Mar 16, 2021 8:57 am

Mr. RAO

This function support TMySQL and MakeTotal
Best Regards,

Richard

Harbour 3.2.0dev (r2402101027) => Borland C++ v7.7 32bit
MySQL v8.0 /ADS v10
Harbour 3.2.0dev (r2011030937) => Borland C++ v7.4 64bit
User avatar
richard-service
 
Posts: 803
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan

Re: FWH 2102: XBrowse:SetMultiSelectCol()

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Ariel » 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.
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: FWH 2102: XBrowse:SetMultiSelectCol()

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Ariel » 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.
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: FWH 2102: XBrowse:SetMultiSelectCol()

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Ariel » Thu Mar 25, 2021 3:49 pm

Mr. Rao,

Perfect!!! Thanks.

Regards.
Ariel
 
Posts: 376
Joined: Wed Nov 29, 2006 1:51 pm
Location: Rosario - Argentina

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Marc Venken » Thu Mar 25, 2021 4:25 pm

Is aSelected() used for the selections in the new way ?

I use this kind of functions many times

Code: Select all  Expand view

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby nageswaragunupudi » Sat Mar 27, 2021 5: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: Select all  Expand view
#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
 


Image
Regards

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

Re: FWH 2102: XBrowse:SetMultiSelectCol()

Postby Silvio.Falconi » Sat Mar 27, 2021 9:37 am

Nages,
is there SetMultiSelectCol() method on xbrowse.prg ?

Code: Select all  Expand view

  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 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: Google [Bot] and 118 guests