Check Box Select/Deselect All on Grid

Your rating: None

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.

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

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

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.

Re: Check Box Select/Deselect All on Grid

HH's picture

Thanks for sharing.
Can you explain when this functionality will be used ?

Re: Check Box Select/Deselect All on Grid

Posts: 302
Join date: 06/23/08
Lepa's picture

Hey HH,
There has been a question on the forum once on whether it is possible to use a dropdown with the ability for the users to make multiple selections BUT after some comments back and forth, it was decided that the best option is to provide a grid to users with the ability to select more than one row (multiple check boxes) and thus this post.

Does it make sense?!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Re: Check Box Select/Deselect All on Grid

Posts: 13
Join date: 03/18/08
Larry's picture

We are using this functionality on a project I am working on currently. Pages contain Multi-row grids, and we have several processes that can be performed on the grid rows if selected--Refresh, Purge, Update Effdt to current week, etc.... The select all logic is a quick & easy way to handle it.

We used a checkbox, rather than a button. One drawback, while manipulating the checkbox works okay, if Select All is checked, and then the user manually unchecks one or more of the individual row selection checkboxes, there is no way to get the Select All indicator flipped to note such a change (i.e. - there can be a situation where not all row indicators are selected, but the Select All checkbox is--almost a sort of Out-of-Sync issue).

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <div> <pre> <br> <code> <a> <em> <blockquote> <strong> <ul> <ol> <li> <dl> <dt> <b> <p> <h1> <h2> <u> <img>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>.

More information about formatting options

CAPTCHA
The question below is to prevent automated spam submissions.
4 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.