Aller au contenu principal
Version: 20 R6 BETA

VP SET DATA CONTEXT

Historique
ReleaseModifications
19 R5Ajout

VP SET DATA CONTEXT ( vpAreaName : Text ; dataObj : Object {; options : Object } {; sheet : Integer} )
VP SET DATA CONTEXT ( vpAreaName : Text ; dataColl : Collection ; {options : Object } {; sheet : Integer} )

ParamètresTypeDescription
vpAreaNameObject->Nom d'objet formulaire zone 4D View Pro
dataObjObject->Objet de données à charger dans le contexte de données
dataCollCollection->Collection de données à charger dans le contexte de données
optionsObject->Options supplémentaires
sheetInteger->Numéro d'indice de la feuille

Description

The VP SET DATA CONTEXT command sets the data context of a sheet. A data context is an object or a collection bound to a worksheet, and whose contents can be used to automatically fill the sheet cells, either by using an autogenerate option or the VP SET BINDING PATH method. On the other hand, the VP Get data context command can return a context containing user modifications.

Dans vpAreaName, passez le nom de la zone 4D View Pro. Si vous passez un nom inexistant, une erreur est retournée.

In dataObj or dataColl, pass an object or a collection containing the data to load in the data context. Les images sont converties en schémas URI de données.

To pass a time value in dataObj or dataColl, encapsulate it in an object with the following properties (see example 4):

PropriétéTypeDescription
valueInteger, Real, Boolean, Text, Date, NullValeur à placer dans le contexte
timeRealValeur heure (en secondes) à placer dans le contexte

In options, you can pass an object that specifies additional options. Il peut contenir les propriétés suivantes :

PropriétéTypeDescription
resetObjectVrai pour réinitialiser le contenu de la feuille avant de charger le nouveau contexte, Faux (par défaut) dans le cas contraire.
autoGenerateColumnsObjectUtilisé uniquement lorsque les données sont une collection. Vrai (par défaut) pour spécifier que les colonnes doivent être générées automatiquement lorsque le contexte de données est lié. In this case, the following rules apply:
  • If dataColl is a collection of objects, attribute names are used as column titles (see example 2).
  • If dataColl contains subcollections of scalar values, each subcollection defines the values in a row (see example 3). The first subcollection determines how many columns are created.

In sheet, pass the index of the sheet that will receive the data context. If no index is passed, the context is applied to the current sheet.

If you export your document to an object using VP Export to object, or to a 4DVP document using VP EXPORT DOCUMENT, the includeBindingSource option lets you copy the contents of the current contexts as cell values in the exported object or document. For more details, refer to the description of those methods.

Exemple

Pass an object and bind the context data to cells in the first row:

var $data : Object

$data:=New object

$data.firstName:="Freehafer"
$data.lastName:="Nancy"

VP SET DATA CONTEXT("ViewProArea"; $data)

VP SET BINDING PATH(VP Cell("ViewProArea"; 0; 0); "firstName")
VP SET BINDING PATH(VP Cell("ViewProArea"; 1; 0); "lastName")

Exemple 2

Pass a collection of objects and generate columns automatically:

var $options : Object
var $data : Collection

$data:=New collection()
$data.push(New object("firstname"; "John"; "lastname"; "Smith"))
$data.push(New object("firstname"; "Mary"; "lastname"; "Poppins"))

$options:=New object("autoGenerateColumns"; True)

VP SET DATA CONTEXT("ViewProArea"; $data; $options)

Exemple 3

The data passed as a parameter is a collection that contains subcollections. Each subcollection defines the contents of a row:

var $data : Collection
var $options : Object

$data:=New collection
$data.push(New collection(1; 2; 3; False; "")) // 5 columns are created
$data.push(New collection) // Second row is empty
$data.push(New collection(4; 5; Null; "hello"; "world")) // Third row has 5 values
$data.push(New collection(6; 7; 8; 9)) // Fourth row has 4 values

$options:=New object("autoGenerateColumns"; True)

VP SET DATA CONTEXT("ViewProArea"; $data; $options)

Example 4 - Date and time syntax

var $data : Collection
var $options : Object

$data:= New collection()

// Dates can be passed as scalar values
$data.push(New collection("Date"; Current date))

// Time values must be passed as object attributes
$data.push(New collection("Time"; New object("time"; 5140)))

// Date + time example
$data.push(New collection("Date + Time"; New object("value"; Current date; "time"; 5140)))

$options:=New object("autoGenerateColumns"; True)

VP SET DATA CONTEXT("ViewProArea"; $data; $options)

Voici le résultat une fois les colonnes générées :

Voir également

VP SET BINDING PATH
VP Get binding path
VP Get data context