Page 1 of 1

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

PostPosted: Tue Jun 09, 2020 11:55 pm
by swingman
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?

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

PostPosted: Tue Jun 16, 2020 11:03 pm
by sbutler
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

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

PostPosted: Wed Jun 17, 2020 12:52 pm
by swingman
Thanks for these pointers I will take a look at them..