Manipulating Data on a Grid: Scroll PeopleCode

When you have a grid that is filled with data; data that you don't want. How do you clear it out and then fill it with the data set that you do want? Well, here are the simple steps to do just that.

Lets say we have a Grid on a page and the main record on the grid is called COMPETENCIES. Well we would first want to define a Rowset object to manipulate. The code for this would look as follows:

Local Rowset &COMPETENCIES;

Next we will want to instantiate the object. Instantiate just means to represent by an instance. If you notice, I am not creating a new Rowset. I am getting the Rowset from the current grid called competencies, using the GetRowSet function. And, I am defining the Grid object as a Rowset.

&COMPETENCIES = &REVIEW(CurrentRowNumber(1)).GetRowset(Scroll.COMPETENCIES);

Once that is complete, I want to remove all rows of data from the Grid. To do that I simply use the Flush method.


&COMPETENCIES.Flush();


Now lets fill the grid with new data that we really want.


&COMPETENCIES.Select(Record.COMPETENCIES,"WHERE EMPLID = :1 AND EVALUATION_ID = :2 AND COMPETENCY IN " | &IN | " AND EFFDT = %DATEIN(:3)", &EMPLID, &EVALUATION_ID, &REVIEW_DT);

What I am doing in the above line of code is selecting the data that I want to use to fill the grid. By selecting the record I am in essence asking to select all the fields that are on the grid from the COMPETENCIES table with the where clause.

Thats it! It's that simple.

If you want to learn more about Object Scroll PeopleCode, check out the book called "A Guide to Programming Object Scroll PeopleCode."

Happy Coding...

转载于:https://www.cnblogs.com/GoDevil/archive/2008/08/08/1263904.html

你可能感兴趣的:(Manipulating Data on a Grid: Scroll PeopleCode)