KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method to Set 4D View Pro Area Selection Unit
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: March 25, 2024

Below is a utility method that will allow the selection unit to be changed.
By default, the selection unit is a cell. This can be changed to a row or a column. For example if row is set, selecting a cell will select the entire row containing the cell.
This is similar to the legacy 4D View feature of PV SET AREA PROPERTY with the pv select mode property.

// Method: VP_SetSelectionUnit
//
// Description:
// Sets Selection Unit for 4D VP Area
//
// Parameters:
// $1 - VP Area Name
// $2 - Selection Mode
// - 0 : cell (Default)
// - 1 : row
// - 2 : column
// ================================================================

#DECLARE($vpArea_t : Text; $selectionMode_l : Integer)

var $res_o : Object
var $jsScript_t; $res_t : Text

$res_o:=WA Evaluate JavaScript(*; $vpArea_t; "Utils.spread;"; Is object)

If ($res_o=Null)
   $jsScript_t:="spread"
Else
   $jsScript_t:="Utils.spread"
End if

$jsScript_t:=$jsScript_t+".getActiveSheet().selectionUnit(GC.Spread.Sheets.SelectionUnit\
  [GC.Spread.Sheets.SelectionUnit["+String($selectionMode_l)+"]])"

$res_t:=WA Evaluate JavaScript(*; $vpArea_t; $jsScript_t; Is text)

Example of use:
VP_SetSelectionUnit("ViewProAreaName"; 2)

The above will set the area's selection mode to Columns. If a use clicks on a cell or makes a selection the column(s) of the selected cells will be selected.