KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Automatically Generate Columns with VP Set Data Context
PRODUCT: 4D | VERSION: 19 R 5 | PLATFORM: Mac & Win
Published On: June 26, 2023

As of 4D v19 R5, use the new VP Set Data Context command to create 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 by using an autogenerate option.

Example:
Pass collection of objects and generate columns automatically:

var $options : Object
var $data : Collection

$data:=New collection()
$data.push(New object("firstname"; "John"; "lastname"; "Smith"; "age"; 30))
$data.push(New object("firstname"; "Jane"; "lastname"; "Doe"; "age"; 60))
$data.push(New object("firstname"; "Joe"; "lastname"; "Smith"; "age"; 70))

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

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