Page 1 of 1
How to? Not focus first field in details view?
Posted: 2019-11-28 17:12
by onoehring
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
Re: How to? Not focus first field in details view?
Posted: 2019-11-28 17:49
by jsetzer
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.
Re: How to? Not focus first field in details view?
Posted: 2019-11-29 05:33
by onoehring
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 (62.47 KiB) Viewed 7193 times
Olaf
Re: How to? Not focus first field in details view?
Posted: 2019-11-29 06:21
by jsetzer
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();
});
Re: How to? Not focus first field in details view?
Posted: 2019-11-29 08:05
by onoehring
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
Re: How to? Not focus first field in details view?
Posted: 2020-02-18 00:05
by ronwill
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
Re: How to? Not focus first field in details view?
Posted: 2020-02-18 11:46
by ronwill
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
Re: How to? Not focus first field in details view?
Posted: 2020-02-18 13:31
by onoehring
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
Re: How to? Not focus first field in details view?
Posted: 2020-02-18 13:55
by jsetzer
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.