How do I restore selected grid row after a find?

David Tremain

Active Member
In a Find/Browse form in an application, I want to be able to execute a row exit that does a find as part of its functionality. But then, I want to restore the user to the row they had selected when they performed the row exit. The find is to update row highlighting, and certain calculated quantities - not to change which records are selected.

I have had no success with system functions Get Selected Grid Row Number(FC Grid, VA frm_CurrentGridRow) and a later call to Get Grid Row(FC Grid, VA frm_CurrentGridRow). VA frm_CurrentGridRow is based on alias [$LIC], a MATH_NUMERIC with a size of 15, no edit rule, and 0 decimals.

I thought of stepping through each grid row, and looking for key information until I found the right record, but was concerned about performance issues when there are a significant number of records included in the grid.

Any suggestions on how to do this? A bookmark / restore feature similar to that found in MS-Word would be helpful.
 
Hi David,

Tell the truth, your issue is not too clear for me yet.

Do you want a "normal Find" finctionality on the same form (e.g. pressing the Find button) and later to restore the original content of the form?

Calling the same form via interconnect and passing some info/flag to it can not solve this issue?

Regrads,

Zoltán
 
For example, when you enter the application, the grid populates with 16 rows. The user selects row 12, and clicks the row exit "X-Ref Orders". The application performs some code, and as the final step, executes a Press Button(HC F&ind). In the find process, as the grid is being repopulated, it detects that the record that was on grid row 12 now has a X-Ref relationship, so it indicates that by changing the highlight of that row.

My problem is that when the grid is fully populated, it displays grid row 1 at the top, and there is no currently selected grid row (if you click a row exit, you get a No Grid Row Selected error).

I want the application, after the Find completes, to put the user back on Row 12, with Row 12 being the currently selected grid row.
 
David,

Try to insert a dummy row before row 12 via InsertGrigBufferRow and delete this row immediately.

Hopefully this action will highlight row 12. If it however highlight the row, but not row 12 than try the insertation after row 12.

Good luck,

Zoltán
 
But I can't even find out which row number is the currently selected row number...The user can select any row, and the program knows (<currently selected row>), but I don't know how to get it to tell me (put the value into a variable I can use later).
 
David,

since you (normally) have no guarantee that Find results will be the same then you are reduced to the approach of going thru the grid rows looking for the match to the key information saved from the selected row prior to the find. This is actually not that slow unless you have a large result set.

If you do in fact expect the result set to be the same after pressing Find then you should be able to do as Zoltan suggested. I would suggest though that you:
1) Make sure the variable you are saving the row number in has a scope of "Form"
2) On the Grid itself set the property to "Disable Page-at-a-Time" Processing

Regards,
 
Sorry for this being so short, but why not just use some Table IO and update the GC values instead of performing a find. or populate a filter ('>=') with the GC value and it will be the first line....

Ben again,
 
I'm not sure I understand your question. You wouldn't change the filter. You WOULD populate the filter in the ER before the 'find' button command.

FC <filter> = GC <value> and leave it with '*' all other times. You could even keep it hidden.

Ben again,
 
The only way I know of that you can change the filter values of fields in the header of a Find/Browse form is to change their FC values (FC UnitOfMeasure = "NT").

If you have additional conditions you're applying to the grid selection, you can use the system functions:
Clear Selection(FC Grid)
Set Selection Append Flag(FC Grid, <Yes>)
Set Selection(FC Grid, F4211, CNDJ, <Greater Than>, SL DateToday, <And>)

Keep in mind that what you set with the Set Selection function is appended to the filters established by header field definitions.

One "trick" I've used is to build the Grid selection statements and include them, followed by a Push Button of F&ind, in the ER of a hidden button. Then, when I want to refresh the grid, I do a Push Button on the hidden button, and the grid refreshes with the new criteria.

Hope that helps.
 
Back
Top