How to? Not focus first field in details view?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

How to? Not focus first field in details view?

Post by onoehring » 2019-11-28 17:12

Hi,

how can I prevent AG from putting the focus on the first field in the details table view?
There must be a very simple way - which I have not found yet ;-)

Thanks already
Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to? Not focus first field in details view?

Post by jsetzer » 2019-11-28 17:49

On document ready call the focus() method like $j("#fieldname").focus();

This will work for normal input fields if they already have been rendered.

But there may be some built in function doing the same for the first field a little bit later.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: How to? Not focus first field in details view?

Post by onoehring » 2019-11-29 05:33

Hi Jan,

I tried this code in the beginning of hooks/tablename-dv.js

Code: Select all

$j(function() {
    document.querySelector("#deselect").focus();    
});
(Same with your line of code)

Unfortunately AG seems to jump back to the field. Notice in the image, that first the back button (zurück) is focused, but then the focus jumps back to the first form field.(Dark start of image as I am refreshing the page).
focusjump_v1.gif
focusjump_v1.gif (62.47 KiB) Viewed 5723 times
Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to? Not focus first field in details view?

Post by jsetzer » 2019-11-29 06:21

You are right, I was afraid there is something like this inside for a while now.

Please try to disable AppGini's default behaviour with the following javascript code in TABLENAME-dv.js:

Code: Select all

AppGini.focusFirstFormElement = function() { /*noop*/ };
You should be able to implement your own focus-function now, for example:

Code: Select all

$j(function() { 
  $j("#deselect").focus(); 
});
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: How to? Not focus first field in details view?

Post by onoehring » 2019-11-29 08:05

Hi Ja,

as always: Perfect solution.
In my case your one-liner was enough, as I just needed to remove the focus.

Thank you very much
Olaf

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to? Not focus first field in details view?

Post by ronwill » 2020-02-18 00:05

Hi,

I tried it and unfortunately it didn't work in my case (?) so I changed the following line in my templateDV:
from: setTimeout(AppGini.focusFirstFormElement, 1500);
to: setTimeout(AppGini.focusFirstFormElement, 150000);

and whilst that means editing the templateDV file each time (or write protecting it to preserve the change on generating appgini project) it works for me. Is there a way to globally change the timeout for auto focusFirstFormElement ?

Cheers,
Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to? Not focus first field in details view?

Post by ronwill » 2020-02-18 11:46

My Bad!

It does work for me now, seems I didn't have clear cached images and files checked in my Chrome browser to clear in my default settings.

Cheers,
Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: How to? Not focus first field in details view?

Post by onoehring » 2020-02-18 13:31

Hi Ron,

thanks for reporting back. When reading your 150,000 value - which equals 150 seconds something seemed strange to me. Glad, that you found your solution.
Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to? Not focus first field in details view?

Post by jsetzer » 2020-02-18 13:55

Clearing the cache is extremely important when programming Javascript. There are keyboard shortcuts for every browser.

If you are interested, you may have a look here:
https://appgini.bizzworxx.de/support/troubleshooting/

The first box of my troubleshooting guide lists the keyboard shortcuts for clearing cache + reloading the current page in most popular browsers.

Annotation: Almost every day users are asking me for support on javascript bugs they have. It happened to me that a few of them even got angry with me (?!) although I was trying to help them (for free by the way) to narrow down their problems. And sometimes, after spending too much time on searching for bugs, a simple CTRL+R "fixes" their "bugs". I really recommend getting used to using the keyboard shortcuts. It will save you hours on searching for bugs which do not exist.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply