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
Formedit - how to set default value of select-field?
25/06/2009
13:31
Avatar
roman1983
Member
Members
Forum Posts: 3
Member Since:
25/06/2009
sp_UserOfflineSmall Offline

How is it possible to pre-select a value in a input-field of type "select" ?

25/06/2009
16:25
Avatar
jmcleod3
Member
Members
Forum Posts: 33
Member Since:
04/05/2009
sp_UserOfflineSmall Offline

Hi,

You mean like a default selection?

John

It's not who I am underneath, but what I do that defines me.

25/06/2009
18:01
Avatar
roman1983
Member
Members
Forum Posts: 3
Member Since:
25/06/2009
sp_UserOfflineSmall Offline

hi!

yes - for example my grid has a row: (1, customer 2, yes) and "yes" is a select-entry with [1:yes,0:no]

if i edit a entry with the value "no" it is not selected in the form.

26/06/2009
07:40
Avatar
jmcleod3
Member
Members
Forum Posts: 33
Member Since:
04/05/2009
sp_UserOfflineSmall Offline

To answer: How is it possible to pre-select a value in a input-field of type “select” ?

I've used this in a grid I'm currently working on.

Within the colModel, I have a row (states).

To set a default value for a select just use the 'editoptions' property and the 'defaultValue' option.

{name:'state',index:'state', width:50,
     editable:true,
     edittype:'select',
     editoptions:{dataUrl:'states.txt', defaultValue:'MI'}
},

Hope this helps.

John

It's not who I am underneath, but what I do that defines me.

26/06/2009
08:32
Avatar
roman1983
Member
Members
Forum Posts: 3
Member Since:
25/06/2009
sp_UserOfflineSmall Offline

Hi John,

that is not exactly what i am looking for.

for example:

{
name : 'status',
index : 'status',
width : 80,
editable : true,
edittype : "select",
editoptions : {
value:{0:'Rechnung offen',1:'Rechnung versendet',2:'Erste Mahnung',3:'Zweite Mahnung',9:'Bezahlt'}
}

And if have already added some items to my database. So figure out this entry:

name: Peter Maffay | status: 3

If i click on the row a want to edit this item, the editform opens but the status is set to "0".

27/06/2009
11:55
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

The default value works for adding row. If you are in edit mode the value that is in the grid is selected in the edit form. If the value can not be found (i.e. there are differences in the grid data and the definitions in editoptions) the first value is used. In order to do what you want in edit mode you maybe will need to use beforeShowForm event.

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.

11/02/2010
15:59
Avatar
gotoBirba
New Member
Members
Forum Posts: 2
Member Since:
17/10/2009
sp_UserOfflineSmall Offline

tony said:

Hello,

The default value works for adding row. If you are in edit mode the value that is in the grid is selected in the edit form. If the value can not be found (i.e. there are differences in the grid data and the definitions in editoptions) the first value is used. In order to do what you want in edit mode you maybe will need to use beforeShowForm event.

Regards

Tony


maybe i can save someone for tearing his hairs out……. Wink

in my case….(in form editing: select value forgot his grid-value and showed first-select value...) it does the trick… Laugh )

be carefull with MySql zerofilled fields………………….

server routine that return HTMLselect must return

….

"<option value=".intval($row[id]).">$row[name]</option>"

….

so… we can trim leading '0' from value…… and it works….

it take me about 2 hour of docs+forum… till i find this topic…..

thanks Tony..! Wink

17/06/2010
17:06
Avatar
gseroul
Member
Members
Forum Posts: 15
Member Since:
19/02/2010
sp_UserOfflineSmall Offline

Hi,

I have a similar problem : I use a grid and the edit form option. The first time I edit a line in my form I have the GET request which ask the server for the select values => the 1st value is selected by default (and not the current row value). If I close the form and click again on edit => no more Get as select values are kept in memory (recreateForm false by default) and now the default value in the select is OK, and this for all rows I want to edit.

If I set property recreateForm to true => I have a get on the server to get select values each time => the select in the form have by default the 1st value in the list (which is wrong), even if I close and edit again.

My conclusion (on my code here) is that each time there is a get for select value on the server the default value is wrong (the 1st in the list). If we keep this list in memory then all other edition will have correct default value (mean the current value of the row).

On Safari the select have no default value => white, but closing the form and re-editing is ok.

On Opera I have the 1st value by default each time, even if the list is not recreated....

Also my select is like this :

<select>
<option value='1'>crystalquick_rw</option>
<option value='3'>corning_96</option>
<option value

='4'>corning_192</option>
<option value='6'>crystalquick_sw_new1</option>
<option value='7'>crystalquick_sw_new2

</option>
</select>
In the row showed to users there is not the value 4 but the associated name :

corning_192,
then jqgrid have to deal with the name to find the current value.
Maybe this is the cause ?
Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
30 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