Grid Class Methods

In this section, we discuss each Grid class method.

Syntax

EnableColumns(&Array)

Description

Use this method to enable or disable one or more columns in a grid. When a column is enabled, it is editable; when it’s disabled, it is un-editable.

The EnableColumns method of the Grid class can provide a noticeable performance improvement over multiple calls to set the Enabled property of the GridColumn class. Each call manipulating a grid (either using a Grid class method or setting a GridColumn property) has a significant, and similar performance overhead. Therefore, one key to increasing the performance of PeopleCode programs manipulating grids is to reduce the number of these calls. Performance testing data suggests that if your program is changing three or more columns, use one of the Grid class methods, such as the EnableColumns method, instead of setting the column properties directly. The single call to the Grid class method offsets the small overhead of creating and populating the required array.

Parameters

Field or Control

Definition

&Array

Specify a two-dimensional array containing the column name and a value (Y/N) indicating whether the column is enabled.

Returns

None.

Example

&AREnable = CreateArrayRept(CreateArrayRept("", 2), 0);
&AREnable.Push(CreateArray("JOB_DETAIL", "Y"));
&AREnable.Push(CreateArray("JOB_TIME", "Y"));
&myGrid.EnableColumns(&AREnable);

Syntax

GetColumn(columnname)

Description

The GetColumn method instantiates a grid column object from the Grid class, and populates it with a grid column from the grid object executing this method. Specify the grid column name in the page field properties for that field, consisting of any combination of uppercase letters, digits and "#", "$", "@", and "_".

To specify a grid column name:

  1. Open the page in Application Designer, select the grid and access the page field properties.

  2. Select the Columns tab on the grid properties.

  3. Either double-click on the grid column you want to name, or select the column and click the Properties button.

  4. On the General tab, type the grid column name in the Page Field Name field.

Note: Although it’s possible to base multiple grid columns on the same record field, the Page Field Name you enter for each grid column must be unique, not just for that grid, but for that page. If you have two grids on a page, every page field name must be unique to the page.

Parameters

Field or Control

Definition

columnname

Specify a string containing the value of the Page Field Name on the General tab of the grid column’s properties. You must have previously entered a value for the Page Field Name for the grid column you want to work with.

Returns

A GridColumn object populated with the grid column specified as the parameter to this method.

Example

local Grid &MYGRID;
local GridColumn &MYGRIDCOLUMN;

&MYGRID = GetGrid(PAGE.EMPLOYEE_CHECKLIST, "EMPL_GRID");
&MYGRIDCOLUMN = &MYGRID.GetColumn("CHECKLIST_ITEMCODE");

The following function loops through rows on a grid. The function finds each row that is selected. It does this through the Selected property of the Row class of PeopleCode. Data is then moved from the selected row to a new row, on a different grid, in the same page. The way in which this function is written, data is moved from &SCROLL_SHELF to &SCROLL_CART. These are two different rowset objects, of two different grids, on the same page. Note that the two grids in this example are on the same occurs level.

/* Moving data between grids on the same occurs level */
/* of the same page */

Local Rowset &SCROLL_CART, &SCROLL_SHELF;

Function move_rows(&SCROLL_CART As Rowset, &SCROLL_SHELF As Rowset);

   &I = 1;
/* loop to find whether row is selected */
   Repeat
   If &SCROLL_SHELF.GetRow(&I).Selected = True Then

      If All(&SCROLL_CART(1).GetRecord(1).QEPC_ITEM.Value) Then

         &SCROLL_CART.InsertRow(&SCROLL_CART.ActiveRowCount);
      End-If;

   /* if it is selected move data to other grid   */

      &SCROLL_SHELF.GetRow(&I).GetRecord(1).CopyFieldsTo(&SCROLL_CART.GetRow(&SCROLL_CART.ActiveRowCount).GetRecord(1));

/* delete row from current grid so data disappears  */

      &SCROLL_SHELF.DeleteRow(&I);
      &I = &I - 1;
   End-If;

   &I = &I + 1;
   Until &I = &SCROLL_SHELF.ActiveRowCount + 1;

/* end of loop ****************************************/

End-Function;

/********* end of function *****************************/

/* Creating the rowset object */

&SCROLL_CART = GetLevel0()(1).GetRowset(SCROLL.QEPC_CART);
&SCROLL_SHELF = GetLevel0()(1).GetRowset(SCROLL.QEPC_SHELF);

/* calling the function   */

move_rows(&SCROLL_CART, &SCROLL_SHELF);

Syntax

LabelColumns(&Array)

Description

Use this method to set the display label for one or more columns in a grid.

The LabelColumns method of the Grid class can provide a noticeable performance improvement over multiple calls to set the Label property of the GridColumn class. Each call manipulating a grid (either using a Grid class method or setting a GridColumn property) has a significant, and similar performance overhead. Therefore, one key to increasing the performance of PeopleCode programs manipulating grids is to reduce the number of these calls. Performance testing data suggests that if your program is changing three or more columns, use one of the Grid class methods, such as the LabelColumns method, instead of setting the column properties directly. The single call to the Grid class method offsets the small overhead of creating and populating the required array.

Parameters

Field or Control

Definition

&Array

Specify a two-dimensional array containing the column name and a value for the column label.

Returns

None.

Example

&ARLabel= CreateArrayRept(CreateArrayRept("", 2), 0);
&ARLabel.Push(CreateArray("JOB_DETAIL", "Job Detail"));
&ARLabel.Push(CreateArray("JOB_TIME", "Job Time"));
&myGrid.LabelColumns(&ARLabel);

Syntax

SetProperties(&Array)

Description

Use this method to set multiple properties (column enabled, column visibility, and column label) for one or more columns in a grid.

The SetProperties method of the Grid class can provide a noticeable performance improvement over multiple calls to set individual properties of the GridColumn class. Each call manipulating a grid (either using a Grid class method or setting a GridColumn property) has a significant, and similar performance overhead. Therefore, one key to increasing the performance of PeopleCode programs manipulating grids is to reduce the number of these calls. Performance testing data suggests that if your program is changing three or more columns, use one of the Grid class methods, such as the SetProperties method, instead of setting the column properties directly. The single call to the Grid class method offsets the small overhead of creating and populating the required array.

Parameters

Field or Control

Definition

&Array

Specify a four-dimensional array containing the column name, a value (Y/N) indicating whether the column is enabled, a value (Y/N) indicating whether the column is visible, and a value for the column label.

Returns

None.

Example

&ARProp= CreateArrayRept(CreateArrayRept("", 4), 0);
&ARProp.Push(CreateArray("JOB_DETAIL", "Y", "Y", "Job Detail"));
&ARProp.Push(CreateArray("JOB_TIME", "Y", "Y", "Job Time"));
&mygrid.SetProperties(&ARProp);

Syntax

SetRowHeader(&array_of_cols)

Description

Use the SetRowHeader method to set grid column headers for screen reader mode (for the entire grid when there are no tab separators or for each tab separator when tab separators are present).

Parameters

Field or Control

Definition

&array_of_cols

Specifies an array of string values containing the column names to be set as row headers. A column name is the Page Field Name of the field for the column.

In the case of a grid with no tab separators, this array can contain up to two column names.

In the case of a grid with tab separators, this array can contain up to two column names for each tab separator with the column name to be selected from the group of columns under control of that tab separator.

Returns

(Optional) A Boolean value: True if the method executed successfully; False otherwise.

Example 1

The following example is for a grid without tab separators:

Local Grid &MYGRID;

&MYGRID = GetGrid(%Page, "QRY_VIEWERS_WRK");
&GridRowHeaders = CreateArrayRept("", 0);
&GridRowHeaders.Push("QRYNAME");
&GridRowHeaders.Push("DESCR");
&MYGRID.SetRowHeader(&GridRowHeaders);

Example 2

The following example is for a grid with two tab separators:

Local Grid &MYGRID;

&MYGRID = GetGrid(%Page, "PSCONQRSSRCH_VW");
&GridRowHeaders = CreateArrayRept("", 0);
&GridRowHeaders.Push("CONQRSNAME");
&GridRowHeaders.Push("DESCR");
&GridRowHeaders.Push("QRYOWNERTRANS");
&MYGRID.SetRowHeader(&GridRowHeaders);

Syntax

ShowColumns(&Array)

Description

Use this method to set the visibility for one or more columns in a grid.

The ShowColumns method of the Grid class can provide a noticeable performance improvement over multiple calls to set the Visible property of the GridColumn class. Each call manipulating a grid (either using a Grid class method or setting a GridColumn property) has a significant, and similar performance overhead. Therefore, one key to increasing the performance of PeopleCode programs manipulating grids is to reduce the number of these calls. Performance testing data suggests that if your program is changing three or more columns, use one of the Grid class methods, such as the ShowColumns method, instead of setting the column properties directly. The single call to the Grid class method offsets the small overhead of creating and populating the required array.

Parameters

Field or Control

Definition

&Array

Specify a two-dimensional array containing the column name and a value (Y/N) indicating whether the column is visible.

Returns

None.

Example

&ARShow= CreateArrayRept(CreateArrayRept("", 2), 0);
&ARShow.Push(CreateArray("JOB_DETAIL", "Y"));
&ARShow.Push(CreateArray("JOB_TIME", "Y"));
&myGrid.ShowColumns(&ARShow);