We will provide instructions on how to hide and unhide a grid on a page using PeopleCode when a checkbox is selected. When the checkbox is checked, the grid should be visible, and when unchecked, the grid should be hidden and all values within the grid should be deleted.

To hide the grid, the function “HideAllRows()” is used to hide all rows of the rowset. The following PeopleCode can be written at field change of the checkbox to achieve this:

&Rowset0 = GetLevel0();
&Row0 = &Rowset0(1);
&Rowset1 = &Row0.GetRowset(Scroll.);
&Rowset1.HideAllRows();

/*or */

&rs = GetLevel0()(1).GetRowset(Scroll.table_name);
&rs.HideAllRows();

To delete the data from the grid, the following PeopleCode can be used:

&Rowset0 = GetLevel0();
&Row0 = &Rowset0(1);
&Rowset1 = &Row0.GetRowset(Scroll.);
For &i = &Rowset1.ActiveRowCount To 1 Step - 1
   &Rowset1.DeleteRow(&i);
End-For;

Alternatively, if the data is present in the component buffer and not present in the database, the function “Flush()” can be used to delete the data from the buffer:

&Rowset0 = GetLevel0();
&Row0 = &Rowset0(1);
&Rowset1 = &Row0.GetRowset(Scroll.table_name);
&Rowset1.Flush();

To unhide the grid, the function “ShowAllRows()” is used. The following PeopleCode can be written at field change of the checkbox to achieve this:

&Rowset0 = GetLevel0();
&Row0 = &Rowset0(1);
&Rowset1 = &Row0.GetRowset(Scroll.table_name);
&Rowset1.ShowAllRows();

or

&rs = GetLevel0()(1).GetRowset(Scroll.table_name);
&rs.ShowAllRows();

By using these PeopleCode functions, you can hide and unhide the grid on a page depending on the status of a checkbox.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *