Forum


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.
08:32

25/06/2009

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".
11:55

Moderators
30/10/2007

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.
15:59

17/10/2009

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…….
in my case….(in form editing: select value forgot his grid-value and showed first-select value...) it does the trick… )
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..!
17:06

19/02/2010

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 ?
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66