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 RUN
- 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 RUN
#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