Possible to request focus in a NG-client list component?

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

Possible to request focus in a NG-client list component?

Postby swingman » Tue Jun 09, 2020 11:55 pm

Hi all,

I'm on 2020.03 NG-Client and playing with Form Components.

Each person may know how to speak several languages.

I have a form component (People) containing a list component container with a list component (Languages) showing person_to_languages related records.
In my People entity I created a function for creating a new related record in person_to_languages and it shows up fine in my language list.
I can click into the fields of my new record to edit, but in the Smart Client I took the user right to the first field for data entry by using requestFocus().

I would like to do the same in the NG-Client. The first field of a language is a TYPEAHEAD.
Since the entity does not know about the UI, my entity method calls a scoped method to try to request focus.
I have tried
Code: Select all
forms.person.elements.formcomponent_7.containedForm.listformcomponent_3.containedForm.language.requestFocus();


The field border kind of flashes, but the TYPEAHEAD menu does not drop down.

Any ideas?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1374
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: Possible to request focus in a NG-client list component?

Postby sbutler » Tue Jun 16, 2020 11:03 pm

This doesn't directly answer your question, but thought I'd bring it up since you are still just testing with NGClient...

swingman wrote:Since the entity does not know about the UI, my entity method calls a scoped method to try to request focus.


That's generally not best practices to have an entity method call out to anything that touches the UI. You really want some separation between the model (entity methods) and the view (servoy form) if you think of it that way. I'd suggest taking a look at the svyUtils module at https://github.com/Servoy/svyUtils/ and specifically the svyEventManager functions. They offer a pub/sub style where you can register an event in your entity method, and then subscribe to that event from your other scope methods that touch the UI. So in that way, they are not married together but just loosely coupled and can exist without each other.

Back to your original question. I'd guess that level of customization isn't available in the typeahead component (to trigger it to drop down when its in a list). So, you could try to modify the component to add an API to do that, or just execute some client-side JavaScript to do it manually using our free NgClientUtils plugin http://servoycomponents.com/components/web-components
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 726
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Possible to request focus in a NG-client list component?

Postby swingman » Wed Jun 17, 2020 12:52 pm

Thanks for these pointers I will take a look at them..
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1374
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 6 guests