VP SET DATA CONTEXT
Historique
Release | Modifications |
---|---|
19 R5 | Ajout |
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ètres | Type | Description | ||
---|---|---|---|---|
vpAreaName | Object | -> | Nom d'objet formulaire zone 4D View Pro | |
dataObj | Object | -> | Objet de données à charger dans le contexte de données | |
dataColl | Collection | -> | Collection de données à charger dans le contexte de données | |
options | Object | -> | Options supplémentaires | |
sheet | Integer | -> | 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é | Type | Description |
---|---|---|
value | Integer, Real, Boolean, Text, Date, Null | Valeur à placer dans le contexte |
time | Real | Valeur 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é | Type | Description |
---|---|---|
reset | Object | Vrai pour réinitialiser le contenu de la feuille avant de charger le nouveau contexte, Faux (par défaut) dans le cas contraire. |
autoGenerateColumns | Object | Utilisé 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:
|
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 :