Delete All Grid Rows

Your rating: None Average: 5 (2 votes)

A very simple yet very useful code to give users the option to delete all grid rows on a page at once. I've implemented such a requirement by placing a "Delete all" button above a grid to give PeopleSoft users the option to delete all rows at once instead of clicking the "-" grid button. If the gird has, lets say, 20 rows, then a user will have to click the "-" delete grid button 20 times to delete all rows, compared to one click on the "Delete all" button.

Place the code below behind a field change event.

   &RECCNT = ActiveRowCount(Record.record_name_behind_grid);
   For &I = &RECCNT To 1 Step - 1
      DeleteRow(Record.record_name_behind_grid, &I)
   End-For;

It is important to point out that users will still have to save the page for the deletion to take place at the database level.

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.
ChiDONEt's picture
User offline. Last seen 1 year 47 weeks ago. Offline
Joined: 09/24/2008
Posts: 8
Re: Delete All Grid Rows

Another form -Visual-:

Local Rowset &MiRowSet = GetRowset(Scroll.MyScroll);
&MiRowSet.Flush();

The records will be deleted from the buffer not from the DB.... if you want to delete from DB in the same buttom:

Local SQL &MySQL;
&MySQl = CreateSQL("Delete from %Table(:1) where KEY1 = :1 And ...",Record.MyTable,&MyKeys)

Post new comment

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