Thursday, January 29, 2015

PeopleSoft IsUserSorted Example with Grid Whose NoAutoSelect Property is Set to True

When a user clicks on a column header in a PeopleSoft grid to sort that column, the grid's IsUserSorted property is set to true. When, in addition, that grid's NoAutoSelect property is set to True, then the RowSet.Sort() function is essentially ignored.  The best solution I can think of in that case is to perform a transfer back to the page so that the identical sort routine on the page's Activate method can be allowed to solve this problem

I have a push button on my page that is used to refresh my rsApplications rowset.  The button's FieldChange PeopleCode is below.  It checks to see if the user has sorted any of the columns, and if so, instead of re-selecting and resorting the data, it sets the appropriate key fields in a search record and uses that search record's values to Transfer back to the page.


Local Rowset &rsApplications = GetLevel0()(1).GetRowset(Scroll.MY_RECORD);
&rsApplications.Flush();
If &rsApplications.IsUserSorted(%Page | ".MY_GRIDS_PAGE_FIELD_NAME") Then
   Local Record &rec_Search_Rec = CreateRecord(Record.MY_COMPONENTS_SEARCH_RECORD);
   &rec_Search_Rec.EMPLID.Value = PERSONAL_DATA.EMPLID;
   Transfer( False, @("Menuname." | %Menu), BarName.USE, ItemName.MY_MENU_ITEM, Page.MY_PAGE, %Action_UpdateDisplay, &rec_Search_Rec, True);
Else
   &rsApplications.Select(Record.MY_RECORD, "where emplid = :1", PERSONAL_DATA.EMPLID.Value);
   &rsApplications.Sort(MY_RECORD.MY_FIRST_COLUMN, "D", MY_RECORD.MY_SECOND_COLUMN, "A");
End-If;


No comments: