Set Focus on a specific Grid Row

BOster

BOster

Legendary Poster
Is there any way to set the focus to a specific row in a Grid (GetGridRow sets *cursor* to the specific row, but doesn't move the focus).
 
Hi Brian,

You can do it and it was described more times here, on JDEList.
I do not remember, who had publicated this technique originally (but thank her/him):

Insert a dummy Grid Buffer Row over (or under?) the row and delete that dummy grid row. Please, try it and let us know, does it work or not - and if it does then the over or under version does. Thanks.

Read you later,

Zoltán
 
Hi Brian,

Glad to know, that it works, but would be more glad to know, over or under?

Waiting...

Zoltán
 
Short Answer: Above

Much Much Longer Answer:
For my specific application I was loading a grid from cache and the focus was being set to the last record which was several pages down. What I did was to insert my cache records using a grid number variable and incrementing the grid number var in the loop. I changed the grid num var to start inserting at row 2 instead of row 1 and at the end of the loop inserted a blank row at row 1 and then deleted it.
 
[ QUOTE ]
Hi Brian,

Insert a dummy Grid Buffer Row over (or under?) the row and delete that dummy grid row. Please, try it and let us know, does it work or not - and if it does then the over or under version does. Thanks.

Read you later,

Zoltán

[/ QUOTE ]

Hi Zoltán,

I tried your suggestion on an application I'm working on right now, but it doesn't work. I also tried my own solution (1. copy the grid row in question to grid buffer; 2. delete that grid row; 3. re-insert that row from buffer back to grid), which I've used in several other applications, and which usually works, but that one ALSO didn't work in my current application! Could it have something to do with the fact that the form I'm currently working on is a Find/Browse?
confused.gif


(edit:) Additional info: Using the ER debugger, I can see that the row is inserted/deleted, but the focus remains on the first row in the grid.

(Current environment is on Xe, SP 23_L1).
 
Well, seemed to work for me... I guess. Of course this doesn't actually select the record or anything like that. The problem I was having was that the grid was getting filled from cache and the first record would scroll off the page and the last record in the grid would be visible. After implementing the above solution, the grid is filled and the first page of data is displayed instead of the last page (you have to scroll to the last page instead of having to scroll to the first page). That was really all I was trying to accomplish and it appears to work... didn't really go any further to see where the focus was actually set, it just appeared to be set on the first row like I wanted. Here is the ER code off the Find button if it will help:

WarningApplication: Supplemental Forms for P4915 (P564915S)


=======================================================================
FORM: Work With Shipments - Sort Sequence [HEADERLESS DETAIL] (W564915SB)
=======================================================================
CONTROL: HYPITEM F&ind
EVENT: Post Button Clicked
-----------------------------------------------------------------------
evt_cEndOfList
evt_idCursorHandle
evt_mnGridRow
//
// Fill Grid from Cache
VA frm_cLoadingGrid = "1"
VA evt_mnGridRow = "1"
VA evt_idCursorHandle = "0"
VA evt_cEndOfList = "0"
While VA evt_cEndOfList is not equal to "1"
Acme W4915B Sort Seq - Next
FI idSessionHandle -> idSessionHandle
VA evt_idCursorHandle <> idCursorHandle
VA evt_cEndOfList <- cEndOfList
GB nKey [HIDDEN] <- nKey
GB Data Item <- szDataItem
GB Column <- szDescription
GB Sort Sequence <- mnSequence
GB Sort Order <- cSortOrder
If VA evt_cEndOfList is not equal to "1"
VA evt_mnGridRow = [VA evt_mnGridRow]+1
Insert Grid Buffer Row(FC Grid, VA evt_mnGridRow, <Yes>, <No>, <Yes>, <No>, <Yes>)
Get Grid Row(FC Grid, VA evt_mnGridRow)
Press Button(FC SetGridRowFormat)
End If
End While
VA frm_cLoadingGrid = "0"
VA evt_mnGridRow = "1"
Insert Grid Buffer Row(FC Grid, VA evt_mnGridRow, <No>, <Yes>, <No>, <Yes>, <Yes>)
Delete Grid Row(FC Grid, VA evt_mnGridRow)
//
 
Hi Boster,

A while ago I also had to fix a similar situation: After records were loaded from cache, the focus would go to the last record in the grid, and the customer wanted the focus on the 1st row (For exactly the same reason you mentioned).

I solved that one as follows using my own solution, which, like I mentioned earlier doesn't seem to work in my current application:

Listing of ER for Application : Configured Item Specifications (P32942)

=======================================================================
FORM: Configured Item Specifications [HEADERLESS DETAIL] (W32942A)
=======================================================================
CONTROL: FORM
EVENT: Post Dialog is Initialized
-----------------------------------------------------------------------

(. . .)

// Load grid from cache.
Press Button(FC Load Grid)

(. . .)

// .
// ===========================================================
// Issue 1078 - 18/10/05 - BEGIN
// .
// Set focus back on 1st row in grid as follows:
// .
// 0. Clear grid buffer.
Clear Grid Buffer(FC Grid)
// .
// 1. Save 1st row to buffer.
Copy Grid Row To Grid Buffer(FC Grid, "1")
// .
// 2. Delete 1st row from grid.
Delete Grid Row(FC Grid, "1")
// .
// 3. Re-insert 1st row in grid (This sets the focus on the 1st row).
Insert Grid Buffer Row(FC Grid, "1", <Yes>, <Yes>, <Yes>, <No>, <Yes>)
// .
// Issue 1078 - 18/10/05 - END
===========================================================
// .

This one is also a H/D form. I'm beginning to suspect it really has to do with the fact that my current application has a F/B form. If anyone manages to get it to work on a F/B form (using either the method Zoltán mentioned, or my alternative), or can confirm that it won't work on an F/B form (and knows the reason why it won't work), then let me know.
 
[ QUOTE ]
Could it have something to do with the fact that the form I'm currently working on is a Find/Browse?

[/ QUOTE ]

I too tried doing the same changes to a Find Browse form and got the same results like you. i.e I cannot make any row selected by default.

But there possibly has to be a way since for eg, in P92002 (Work With Glossary Items) Find Browse form, if you press Find, the first row is auto selected. Select the Row Exit Glossary and you'll see the glossary for the first row.
 
[ QUOTE ]

I too tried doing the same changes to a Find Browse form and got the same results like you. i.e I cannot make any row selected by default.

[/ QUOTE ]

Glad to see someone who can confirm this. So I’m not going senile after all (or so it seems ;-)).

[ QUOTE ]
But there possibly has to be a way since for eg, in P92002 (Work With Glossary Items) Find Browse form, if you press Find, the first row is auto selected. Select the Row Exit Glossary and you'll see the glossary for the first row.

[/ QUOTE ]

As for P92002 : Focus on 1st row after standard “Find” processing (i.e.: No special stuff like load from grid, etc.) is default behaviour (my F/B form does it too). The trick is to find out how to get the focus on a specific row (other than the first).
 
Hi Remo & Shailesh,

Shailesh gave me an idea, what could be the difference in P92002.
If you turn off the Multiple Selection on the grid, then after Find the first row will be selected. I fastly tied it on P01012.

OK, I know, Multiple Selection can be a hard requirement in your scenario.
Maybe, you can play with SetControlFocus(FC Grid) system function too, but I suppose, it won't help also - but you can make a try.

Read you later,

Zoltán
 
Got this working on a Find Browse.

You simply need to delete the grid row rather than the buffer row you inserted - obviously after copying the row details to the buffer row....

============================================================
FORM: Find/Browse [FIND BROWSE] (W57MATTI)
============================================================
CONTROL: BUTTON Push Button 24
EVENT: Button Clicked
------------------------------------------------------------
evt_mnCurrentRowMATH10
0001 //
0002 Get Selected Grid Row Number(FC Grid, VA evt_mnCurrentRowMATH10)
0003 Copy Grid Row To Grid Buffer(FC Grid, <Currently Selected Row>)
0004 Delete Grid Row(FC Grid, <Currently Selected Row>)
0005 Insert Grid Buffer Row(FC Grid, VA evt_mnCurrentRowMATH10, <Yes>, <No>, <Yes>, <Yes>, <Yes>)
 
Hi All,

I read this thread of post and it was very helpful for implementing the same for one of the requirement I had, but still I have one more hurdle...

Is there any way to SET THE FOCUS ON A PARTICULAR GRID COLUMN after setting the focus to the desired Grid Row??

Let me give a quick insight of my requirement, I have developed a custom application to read the bar code scanned values, This app has 3 GCs say, A,B and C. and it also has two push buttons (Review and Associate), when the form loads, GC 'C' must be disabled for entry and the user will scan his data into A and B. Then by clicking 'Review' it should disable 'A' and 'B' and enable 'C' and the Focus should be on the first row. Now with the steps suggested I am able to set the focus on the first row, but is there a way to have the focus set to GC 'C' in first row.

Any help is appreciated...

Antony
JDE Consultant
Win2000, WinXP
A7.3,B7333,B7334,E810
 
Hi Antony,

Remo recently pointed to this thread and after I read your last post on it, I got an idea, how to work around.

As far as I know, alway the 1st column get the focus.

Disable all A, B and C field statically and place a DD Item based column as 1st column.

When the user call one of your function pushing the button, then move the appropriate field value into the first column.

You can also override the Column Heading at runtime as well as Visual Assist. If the type of fields are not identical, then you should play a bit with conversion in ER.

At this point I got an other idea, which can solve Type, Visual Assist, Column Heading, Default Value diferrences with less ER code.

Place 3 "first" column, based on the the same Data Item as A, B , D.
When user call your function, hide 2 of 3 and show the appropriate one.

OK, it is a "little bit" late reply
cool.gif


Regards,

Zoltán
 
Zoltan,

Thanks for this post. I can certainly see using this idea in the future or to potentially replace some existing functionality I have used in the past. Good idea!
 
Can anyone confirm whether or not the techniques described in this thread for setting focus on a particular grid row works with a web client? Specifically a 8.98 / E900 web client?

Thanks in Advance,
 
hi larry, i used it in a power edit form in 8.12/web a while ago, and it seemed to work when i tested it (i used the [clear grid buffer/copy grid row to grid buffer/delete grid row/insert grid buffer row] sequence). but if i remember correctly, they did report an issue with it. if i manage to recall what that issue was, i'll let u know.
 
about that issue: i checked with a colleague, cuz i couldn't remember. apparently, customer py-tests showed that it didn't work 100%. but i didn't have any problems during dv-testing. weird. anyway, don't have the details (and i'm afraid i never will, cuz they pulled the plug on the project just before go-live
tongue.gif
)
 
Thx for checking Remo.

I can't get it to work for me in my 9.0 environment ... however this is with an app that populates the grid from cache - not from a bsvw.
 
larry: on a fat, it should work (see my example from W32942A above, where the grid is also populated from cache - this is from 810 btw). dunno about web.

but come to think of it: why would a grid loaded from cache behave differently than one loaded from a businessview? i mean: once the grid has been populated, the system doesn't know where the rows came from anymore, does it? so imo there's no difference (except for the BC datastructure maybe, but i can't imagine that would have any impact on the matter at hand).
 
Back
Top