display.grid.setGridRecNumField()

display.grid.setGridRecNumField()

Description

display.grid.setGridRecNumField() specifies the name of the program field that holds the relative record number (RRN) for a grid. Once an RRN field is set, the subfile-style methods use it in the same way an RPG program uses the SFLRCDNBR field:

The RRN field can also be assigned for one or more grids with the rrnFields configuration option of pjs.defineDisplay(), which is the more common approach. setGridRecNumField() is useful when the field name is not known until run time. In either case the field must be defined in the module with pjs.define().

Syntax

display.gridName.setGridRecNumField(fieldName)

Parameters

  1. Field name (String) - The name of a numeric field, defined with pjs.define(), that will hold the relative record number.

Return Value

Nothing is returned.

Examples

Example 1: Assign an RRN Field and Write a Specific Record

Defines an integer field, assigns it as the RRN field, and writes record 1. Setting the field before each write() controls which record number is written.

Prerequisite: a Rich Display File named subfiled.json with a control record format named ctl and a grid whose record format name is sfl, with the fields product, description, and quantity bound to its columns.

pjs.defineDisplay("display", "subfiled.json"); // Declare the display file pjs.define("rrn", { type: "integer" }); // Declare the RRN field display.sfl.setGridRecNumField("rrn"); // Use rrn as the RRN field for the sfl grid display.sfl.clear(); for (rrn = 1; rrn <= 10; rrn++) { // Write records 1 through 10 product = rrn; description = "ITEM " + rrn; quantity = 0; display.sfl.write(); // Written to record number rrn } display.ctl.execute();

Example 2: Equivalent Configuration with rrnFields

Produces the same result as Example 1 by naming the RRN field in the rrnFields option of pjs.defineDisplay(), which is the recommended approach when the field name is known in advance.

Prerequisite: a Rich Display File named subfiled.json with a control record format named ctl and a grid whose record format name is sfl, with the fields product, description, and quantity bound to its columns.

pjs.defineDisplay("display", "subfiled.json", { rrnFields: { sfl: "rrn" } }); pjs.define("rrn", { type: "integer" }); // The field named in rrnFields must still be defined display.sfl.clear(); for (rrn = 1; rrn <= 10; rrn++) { product = rrn; description = "ITEM " + rrn; quantity = 0; display.sfl.write(); } display.ctl.execute();

Related Pages