Check Box Select/Deselect All on Grid

Your rating: None Average: 4.6 (8 votes)

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;

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.
HH's picture
HH (not verified)
Re: Check Box Select/Deselect All on Grid

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

Lepa's picture
User offline. Last seen 7 weeks 2 days ago. Offline
Joined: 06/23/2008
Posts: 590
Re: Check Box Select/Deselect All on Grid

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

Larry's picture
User offline. Last seen 4 years 42 weeks ago. Offline
Joined: 03/18/2008
Posts: 18
Re: Check Box Select/Deselect All on Grid

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

Guest's picture
Guest (not verified)
Re: Check Box Select/Deselect All on Grid

THANK YOU SOOOOOOOOOOOOOO MUCH
I just started working in PeopleCOde
needed above functionality in my project
I spent like 2 hours, tried implementing this .. but was unsucessful

It took like 5 mins to take above code n it worked .......

God Bless You :)

Junaid's picture
Junaid (not verified)
Re: Check Box Select/Deselect All on Grid

Does any body know if am changing any value in the Grid ( which does not have a check box ) how to check if the value is changed for that row.

Below is the code for which am updating the row with 'LASTUPDTTM' with Current Datetime for which the row was changed. This code is working fine, but somtimes when i update only one row in the grid LASTUPDTTM in that record gets updated for all rows. It should update the LASTUPDTTM only for that row.

Local Rowset &RS;
&RS = GetLevel0()(1).GetRowset(Scroll.Z_CC_PRMTP_TRFN);
For &I = 1 To &RS.ActiveRowCount
If &RS.GetRow(&I).IsChanged Then
&RS.GetRow(&I).Z_CC_PRMTP_TRFN.LASTUPDDTTM.Value = %Datetime;
End-If;
End-For;

Does any one know abt this ?

Ashar's picture
User offline. Last seen 1 year 30 weeks ago. Offline
Joined: 03/26/2008
Posts: 227
Re: Check Box Select/Deselect All on Grid

Hi,

I do not see a reason why the above code should not work but you can try below code in the record SavePreChange PeopleCode. Let us know if it works.

If GetRow().IsChanged Then
Z_CC_PRMTP_TRFN.LASTUPDDTTM.Value = %Datetime;
End-if;

GuestHH's picture
GuestHH (not verified)
Re: Check Box Select/Deselect All on Grid

Lepa
Unless I very wrong,I think this will select all the rows in the buffer. Not just the rows that are currently displayed.

Is it possible to select just the ones currently displayed on the page ?

Guest's picture
Guest (not verified)
how to know whether checbox is checked or not

hai all
please help me out on this issue...

basing on the check box checked we are making the field visible or unvisible...
but the checkbox is in one page and the field... is in other page...
now i need to kow whether the checkbox is checked or not.. that is through peoplecode...

Lepa's picture
User offline. Last seen 7 weeks 2 days ago. Offline
Joined: 06/23/2008
Posts: 590
Re: Check Box Select/Deselect All on Grid

I would thing creating a global variable flag and assigning a value of Y or N should do the trick.

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

Guest's picture
Guest (not verified)
Re: how to know whether checbox is checked or not

First page activate pplcode:define the check box value as 'Y' if it is checked.
Second page u can retrive the value with the following code.
take the value in the variable--> &checkboxvalue.

&checkboxvalue=Fetchvalue(recordname.fieldname)

coffiebite's picture
coffiebite (not verified)
fileattachment

hi
there is a different case with me like... the user select a file through the attachment from the page.what ever file he selects (i.e the data in that file should be populated into the components)... using filelayout actually we load the data into the statging table..can we do this dynamically like wen we are selecting the file accordingly the ae should take the file the file we are selecting and then run and populate the data from that file to existing components...

thanks in advance

Aravind's picture
Aravind (not verified)
Re: Check Box Select/Deselect All on Grid

the select all code is working fine for me,but de select all is not working for me,Can u plz guess me where I am doing the mistake.

Anyway,really helpful one.keep it up.

Post new comment

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