Skip to Main Content
Return to Navigation

Grid Class Methods

In this section, we discuss each Grid class method.

EnableColumns

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

Returns

None.

Example

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

GetColumn

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

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);

LabelColumns

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

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);

SetProperties

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

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);

ShowColumns

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

Returns

None.

Example

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