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 : select does not have the right default value
21/06/2010
12:07
Avatar
gseroul
Member
Members
Forum Posts: 15
Member Since:
19/02/2010
sp_UserOfflineSmall Offline

Hi,

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 always the 1st value in the list as default  (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 values on the server the default value is wrong (the 1st in the list). Having 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 in the page source code (corning_192 => option 4,  should be the default value, but 1 is selected) :

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

Does anybody have an idea about this problem ? I saw few people having problem with default select value.
As it is working well when the list is already created I tried to play with dataInit in editoptions of the corresponding field to close the
form and recall it jus after (then the list is created at the 1st call, the form is closed and reopen with the correct default value).
It is a bit dirty Laugh

Gael


21/06/2010
22:37
Avatar
Renso
PA
Member
Members
Forum Posts: 118
Member Since:
11/09/2008
sp_UserOfflineSmall Offline

gseroul, you need to be careful with this grid, the value that you return and show in the grid's list needs to match the text value and not the option value.

For example I ahev a list of addresses listed and the first column is the type of address, work, home, etc:

<td title="Work" style="text-align: center;">Work</td>

BUT, the dropdown list looks like this:

<select id="TypeOfAddressDTO" name="TypeOfAddressDTO" size="1" class="FormElement">

<option value="1">Work</option>

<option value="2">Mailing</option>

<option value="3">Home</option>

<option value="9">Other</option>

<option value="10">Billing</option></select>

I always thoght the value of the "Name" in colModel has to match the "key" or option value from the drop down list, but it is actually the text value it needs to match. Hope this helps. When the SAVE occurs it posts back the value (for WORK it will post back "1"). If you add a default first value to represent no specific option you can use

<option value="">All</option>

, and when there is no value in the "name" column for that property it will select the first one ("All").

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

Hi,

Thank you for your reply but I may gave a bad explanation of my problem because your answer is not helpfull for me.

My grid column show this value :  "corning_192" (it is coming from the DB). When I edit the row the select list is created the firt time with an ajax request and it looks like in my previous post (just check above). But the default value in this select is the 1st value (<option value='1'>crystalquick_rw</option> => in FF and Opera) and white (nothing) in Safari. If I close the edit form and re-edit the same row (the select list is already created) then in the edit form the select list have the right default value => <option value='4'>corning_192</option>

And until I do not reload the page (then having the select list created) it is working for all rows in my grid. If I reload the page, the first time I edit the row we have the ajax request to get the select values from the DB and then again the 1st value is selected by default....

I tried to set the property recreateForm to true => then each time I edit a row the select list is getting from the server with ajax and then each time wrong default value.

It is like if the code to select the rigth value in the select list (the one showed in the edited row) is called before getting values from the server. Then the 1st time as there are no values in the list => no selected value (then default value is depended on browser), and after when this list already exist then the correct value is selected.

This is my colModelfor the select column

{name:'platetype', width:150, sorttype:'text', editable:true, edittype:"select", editoptions:{
                     dataUrl:'index.php?option=com_platesdetails&task=getPlateTypeList'

}},

and this is edit option :

var editOptions = {
            saveicon:[false],
            closeicon:[false],
            width:400,
            height:210,
            modal:true,
            closeOnEscape:true,
            closeAfterEdit:true,
            reloadAfterSubmit:true,
            url: 'index.php?option=com_platesdetails&task=updatePlate',
            checkOnSubmit:true,
            afterSubmit:updateStatus,
            bottominfo: 'Check the Plate Type !',
            };

If someone have any idea or need more information feel free, this bug (if it is a bug and not something wrong with me Laugh) is really annoying for my application and users.

Thanks to all

Gael

25/06/2010
09:56
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

It is not a bug I think, but a way that Safari and Chrome works.

Also could you please post the exact code which you retrieve from server to build the select.

What you try to do first - add or edit or there is no difference?

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

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

Hi,

Thanks to take time to check my code.

Here is the line in my grid :

FZ020822 24/06/2010 plate_5_hampton Imaging Robot 20 crystalquick_sw

When I edit the line the first time I have this code returning from my server through the ajax request :

<select>
<option value='1'>crystalquick_rw</option>
<option value='3'>corning_96</option> <option value='4'>corning_192</option>
<option value='8'>crystalquick_sw_nextal</option>
<option value='9'>crystalquick_sw+</option >
<option value='10'>crystalquick_sw_treated</option>
<option value='11'>crystalquick_sw_lbr</option>
<option value='15'>greiner sw lbr</option>
<option value='2'>crystalquick_sw </option>
<option value='17'>crystalquick_hd2</option>
</select>

But in this edit form the 1st value of the list ( <option value='1'>crystalquick_rw</option> ) is selected and not this one

as expected : <option value='2'>crystalquick_sw</option>

If I close the edit form and re-edit the same line (or another line) then the default selected value is the right one comparing

to the value in the grid (in this case it shows crystalquick_sw).

How do you select the default value, with javascript ? Maybe the problem comes from the call of this function which

is not good when there is an ajax request to build the select list ? 

If you want I can do some debug on my side, just give me details of where is the code which select the default

value in a select edit form.

Again thanks a lot to look at my problem, and congratulations to your library : it is awesome !!!

Gael

25/06/2010
10:29
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Which version is used? I think this bug is fixed, but could not remember in wich version.

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.

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

The last one : 3.7.1

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

I also tried with 3.6.5 and same behaviour.

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

Hi Tony, any idea or tests that I can do ?

30/06/2010
15:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

For me is really difficult to determine what is happen. In order to resolve, please provide a link to the problem.

If you do so please, do not include the grid min file, but the non minified source code.

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.

10/07/2010
10:33
Avatar
eagle
Member
Members
Forum Posts: 7
Member Since:
16/03/2009
sp_UserOfflineSmall Offline

Hi all. I'm also faced with this issue.

In case of using dataUrl with edittype "select", when we open modal form (adding row for example),

content of select field ajax-ed from server-side php-scripts.

And in case of using Safari/Chrome selects not display default values

For example in Safari my modal form for add-action looks like this

[Image Can Not Be Found]

In case of Google Chrome modal form looks similar 

[Image Can Not Be Found]

But in FireFox all seems good

[Image Can Not Be Found]

My server-side php-script looks like this in my example

<?php

session_start();

include_once("../../incl/mysql_config.inc");

require ("../../incl/auth.inc");

//$n=1;

$spr_user_groups = "<select>";

$r = mysql_query("select * from user_groups order by group_name asc");

while ($row=mysql_fetch_array($r)) {

$spr_user_groups .= "<option value='".$row['id']."'>".$row['group_name']."</option>";

}

$spr_user_groups .= "</select>";

print $spr_user_groups;

?>

And my colModel part in jqGrid is:

{name:"group_name",index:"group_name",editable:true,edittype:"select",

editoptions:{dataUrl:"ajax/switches/select_user_groups.php"},hidden:false,align:"center",search:true,width:8},

Anybody know how to fix this behavior?

Oh, I forget to say, that in my case I use 

"recreateForm:true"

If I set 

"recreateForm:false"

modal form display correct on second open-form action

Sorry for my English :)

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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