Forum


15:05

13/02/2010

Hello,
I'm trying to have a form, and when the user clicks "add" or "edit", the field with focus should not be the first.
Allow me to show an example:
--------------------------------------------------------------
Date: __________________
Time: _________
Description: _______________________
----------------------------------------------------------------
"Date" and "Time" values are suggested automaticaly by the system, so the user in 99% of the time will only fill in the "Description" field.
I don't know if it's relevant, but the "Date" field is a jQuery datepicker.
I've tryed to use the "beforeShowForm" event, but I had no success.
...,
beforeShowForm: function (formid) {
$("#date", formid).val("2010-03-05"); // This value is static only for this example and it works.
$("#time", formid).val("13:01"); // This value is static only for this example and it works.
$("#description", formid).focus(); // Not working. Always defaults to the first field.
},
...
It's not working.
Can anyone please help me?
Regards,
Carlos
18:59

Moderators
30/10/2007

Hello,
Try to use afterShowForm event when you try to focus description.
Do not forget to set the event in both add and edit
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
19:23

13/02/2010

Hello Tony,
I was able to get it working, but I went the hard way.
Using the afterShowForm just by itself didn't solve the problem.
The focus goes to the description field, but the DatePicker dialog is also open.
I also tried to run: $("#date", formid).datepicker('hide'); but that also didn't solve the problem.
The solution I've encountered was to:
1. not create the datepicker in colModel definition, in editoptions.
2. Run the command: $("#date", formid).datepicker({ dateFormat:'yy-mm-dd' }); in afterShowForm, and after the $("#description", formid).focus();
3. Run the command: $("#date", formid).datepicker('destroy'); in onClose event.
This is working, but it doesn't "sound" as the polite way to do this.
Do you suggest any other procedure for me to try?
Best regards,
Carlos
Most Users Ever Online: 715
Currently Online:
29 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66