Wednesday, September 16, 2009

Select All function for Grid Check box


The below function is to be used on a grid with multiple check boxes. Place the code behind a FieldChange event and users will have the option to Select or Deselect grid rows all at once.

Function selectAllRows(&rs As Rowset)
   Local number &i;
   Local Row &row;
   
   For &i = 1 To &rs.ActiveRowCount
      &row = &rs.GetRow(&i);
      /* Make sure we only select visible rows. */
      If &row.Visible = True Then
         &row.Selected = True;
      End-If;
   End-For;
end-function;

/*main line*/
Local Rowset &rs;
&rs = GetLevel0()(1).GetRowset(Scroll.scroll_table);

/*Call Function*/
selectAllRows(&rs);

 

The same code would work for multiple check boxes "Deselect All", just change the name of the function and line &row.Selected = True; to &row.Selected = False;

 

Note : Make sure the Multiple Row (Check Box) is checked on the grid properties.

 

0 comments:

Post a Comment

Total Pageviews

Copyright © Tech & Management Notes