Highlight grid record and select it using the Enter key

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
BFoster
Profound User
Posts: 50
Joined: Fri May 24, 2019 6:26 am
First Name: Ben
Last Name: Foster
Company Name: Manhattan Assurance Company
Contact:

Highlight grid record and select it using the Enter key

Post by BFoster »

I've been asked to highlight a record based upon the cursor location. For example, if the cursor is in the subfile option field of the 3rd record, highlight the fields of that record as if the mouse was hovering over it (which highlights the record). I've searched the API. My thinking is that the solution begins by knowing which record RRN of the grid the cursor is in. Also, they want to be able to press enter to select that record. This is a user community who want to use the mouse as little as possible as it slows data entry. It's all about the metrics.
BFoster
Profound User
Posts: 50
Joined: Fri May 24, 2019 6:26 am
First Name: Ben
Last Name: Foster
Company Name: Manhattan Assurance Company
Contact:

Re: Highlight grid record and select it using the Enter key

Post by BFoster »

Asked and answered.

I happened to stumble upon a variable called row which exposes the RRN of the record the cursor is on. Is there a list of other variables like this that are exposed to the developer?

The following code will allow the user to tab through a subfile (the subfile option field has a column width of zero) and press "Enter" to select the record for processing. The data grid has ID of "S01" and the subfile option field into which a "1" will be placed has ID of "S01OPT". Since the subfile option field has a width of zero the user will not see the cursor or the "1" for that matter. They know which row they have tabbed onto due to the highlighting.


The onfocus event:

Code: Select all

//This will get the grid to select the current row
//to highlight the row.  It will also populate the
//subfile option field S01OPT with a '1' in anticipation
//that the user will press "Enter". If the user does not
//press "Enter" and tabs out of the field  the '1' will be 
//removed by the onblur event.
var grid = getObj("S01").grid;
grid.selectRow(row, false); 
grid.setDataValue(row, "S01OPT", 1);
The onblur event

Code: Select all

//This code will get the grid and deselect the row to
//remove the row highlight.  It also removes the '1'  
//placed into the subfile option field by code in the
//onfocus event.
var grid = getObj("S01").grid;
grid.deselectRow(row); 
grid.setDataValue(row, "S01OPT", ' ');
Last edited by BFoster on Thu Sep 19, 2019 10:59 am, edited 4 times in total.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Highlight grid record and select it using the Enter key

Post by Scott Klement »

The variables like 'row' are documented under the grid events such as
onrowclick https://docs.profoundlogic.com/x/54BQ
onrowmouseover https://docs.profoundlogic.com/x/64BQ

It sounds like you just want to put emphasis on whichever field currently has the focus, though, right? Is it important to highlight the whole row, or is it just important to know where the focus is (to make it easy for the eyes to gravitate towards that spot?)

highlighting the row would only be useful within a grid.
BFoster
Profound User
Posts: 50
Joined: Fri May 24, 2019 6:26 am
First Name: Ben
Last Name: Foster
Company Name: Manhattan Assurance Company
Contact:

Re: Highlight grid record and select it using the Enter key

Post by BFoster »

It sounds like you just want to put emphasis on whichever field currently has the focus, though, right?
Yes.
Is it important to highlight the whole row, or is it just important to know where the focus is (to make it easy for the eyes to gravitate towards that spot?)
Yes and Yes.

I'm using the focus/blur events on the hidden subfile option field to handle the selection/de-selection of the subfile record. See solution above.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests