VL Web - Prevent Field changing when "hovering" List Items

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 651
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

VL Web - Prevent Field changing when "hovering" List Items

Post by jyoung » Wed Jun 08, 2016 4:49 am

I have a panel that on the left side is List control. That control has columns for PhoneDescription and PhoneNumber. On the right side of the panel are the fields PhoneDescription and PhoneNumber along with a save button.

What is happening is that if I have multiple entries in the list, mousing over the entries without selecting them changes the fields on the right.

This leads to a problem that if I have the second item selected, it shows in the right hand fields, then accidentally mouse over the first entry, the right hand fields that had represented the selected item now show the first item.

The way I have dealt with this previously is to bind the list to standard fields that are not the data fields, for example STD_TEXT, STD_STRNG and then hook into on of the List events (ItemClick, ItemGotSelection) to get the item item and then set the data fields to the standard fields.

Is there a better way to deal with this? I keep looking for a setting on the list to turn off the "AutoFocus".

Thanks,
Joe

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: VL Web - Prevent Field changing when "hovering" List Items

Post by Stewart Marshall » Wed Jun 08, 2016 9:22 am

List CurrentItem processing ALWAYS updates the current field values. This cannot be stopped and neither should it be. It's fundamental to VL behaviour.

Your problem is that you've used the same variable name for two jobs. PhoneNumber is in the list, and PhoneNumber is the edit on the page.

Your previous technique of using different fields is one solution, but best practice is to separate the code and make reusable parts for each area of the screen. This may seem like unnecessary work, but using reusable parts to construct the UI is a very good habit to get in to.

Each area of the UI becomes a self contained piece with simple methods and events. For example, you might make an "editor" part with a "Show" method that receives an identifier and loads the data. Add in a Save method, and you have a part that can be used anywhere.

Then do the same with the list. A simple method to load the data and an event to indicate that one has been selected.

Your page code then becomes super simple, detecting the event and passing it on to the editor part.

Code: Select all

Evtroutine Handling(#CustomerList.Selected) ID(#ID)

   #Editor.Show(#ID)

Endroutine
Using parts also simplifies layouts. Each piece looks after its owns needs, so you need only make the simplest of layouts on the page.

In the long run, this separation saves time and effort and makes it far easier for other developers to understand the code.
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

jyoung
Posts: 651
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: VL Web - Prevent Field changing when "hovering" List Items

Post by jyoung » Thu Jun 09, 2016 1:23 am

Ahh, did not think about putting them in separate parts.

Thanks.

Post Reply