Landing in the right field when editing a record

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Landing in the right field when editing a record

Post by wilmira » 2015-06-24 00:12

Hello everybody,

I wonder if it is possible to land in the field that we want to edit instead of the first field of the record. That is, if we have a table with a record containing the fields: name, address, email, telephone, and then we want to edit the telephone field, when we click over that field, the program will take us to the detail view of the table and our cursor will land on the record we have just clicked.

Could it be possible?

Wilfredo

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Landing in the right field when editing a record

Post by a.gneady » 2015-06-24 20:46

Open the file "hooks/tablename-dv.js" in a text editor (where tablename is the name of the concerned table -- create that file in the hooks folder if it doesn't already exist), and add this code:

Code: Select all

$j(function(){
    $j('#phone').focus();
})
Assuming your field name is "phone".
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Landing in the right field when editing a record

Post by wilmira » 2015-06-24 23:54

Hi Ahmad,

Thank you for the code. It works great, however I cannot make it work for 2 or more fields, only for one. Can you give me an example with 2 fields?

Thanks again.

Wilfredo

primitive_man
AppGini Super Hero
AppGini Super Hero
Posts: 54
Joined: 2014-03-09 20:20

Re: Landing in the right field when editing a record

Post by primitive_man » 2015-06-25 12:30

This technique will only work on a single field - it basically overrides the default setting -> first field in the form.

In order to work with multiple fields in Table view, you'd have to add an OnClick event to the tables fields that you wish to enable focus on.
You can do this by editing the table_templateDV.html and the table_dml.php

In the hooks/tablename-dv.js file you'd have to add a listener to see which field in your table had been clicked and then it'd change the focus() based upon this result.

wilmira
Veteran Member
Posts: 67
Joined: 2013-07-11 18:00

Re: Landing in the right field when editing a record

Post by wilmira » 2015-06-25 19:20

Thank you very much.

I will try to implement what you have said.

Wilfredo

Post Reply