Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Form Edit: Setting the focus to a field
05/03/2010
15:05
Avatar
carlos.vita
Member
Members
Forum Posts: 5
Member Since:
13/02/2010
sp_UserOfflineSmall Offline

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

09/03/2010
18:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

15/03/2010
19:23
Avatar
carlos.vita
Member
Members
Forum Posts: 5
Member Since:
13/02/2010
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information