set selected to text value on dropdown

132 views
Skip to first unread message

ram

unread,
Jul 5, 2012, 1:01:08 PM7/5/12
to struts2...@googlegroups.com
Hi

I have just moved from Struts2 Jquery Plugin 2.4.1 to 3.2.0 and I have noticed that in 2.4.1 when I click on an editable row that contains a dropdown list, my text is default selected. Now as I have moved to 3.2.0, it seems that it is using the key value to set selected. This is causing me a major problem.

Can anyone pleas assist as to the quickest fix available for this?

Thanks & much appreciated in advance.

ram

unread,
Jul 5, 2012, 1:13:16 PM7/5/12
to struts2...@googlegroups.com

Hi

Just more info on this.

As per my example below. The text of my column before I select the row is 101.

When I click on the row it becomes editable and the column becomes a dropdown list as expected.

However the dropdown list then automatically defaults to ABC! This is a disaster for me.

 

<option value="" role="option">Please select..</option>
<option value="1" role="option">101</option>
<option value="2" role="option">102</option>
<option value="101" role="option">ABC</option>

 

Obviously, that is default selecting the wrong value. its getting confused because the Key Option for ABC is actually 101 which is the same as my text value for another option.

Anyone got any insight on the best and quickest way i can solve this throughout my app?

Thanks in advance.

jogep

unread,
Jul 6, 2012, 1:37:30 AM7/6/12
to struts2...@googlegroups.com
Where comes the values for your option list? Can you please provide some sources?
 

ram

unread,
Jul 6, 2012, 7:19:08 AM7/6/12
to struts2...@googlegroups.com
Hi Johannes

This is how I declared my column:

<sjg:gridColumn name="system.systemNo" index="systemHeader" title="%{getText('label.system')}" 
    editable="%{isEditableForUser}" edittype="select" editoptions="{dataUrl : '%{retrieveSystemListUrl}'}" editrules="{required:true}" 
    formoptions="{elmprefix:'%{getText('label.mandatory')} '}" sortable="true" search="true" width="160"/>


<s:url id="retrieveSystemListUrl " action=" retrieveSystemListUrl.action" namespace="/qa"/>

retrieveSystemListUrl call returns a jsp which gets popules a select option by this:
<s:select list="systemList" theme="simple" listKey="systemId" listValue="systemNo" headerKey="" headerValue="%{getText('label.pleaseSelect')}"/>
I only just noticed this issue now as I am about to go live on Sunday..:-(

Please any assistance or suggestions is welcomed.

Thank you

ram

unread,
Jul 7, 2012, 6:35:36 AM7/7/12
to struts2...@googlegroups.com
I can reproduce this now Using the 3.2.0 Showcase Grid

Change the country colum in grid-edit.jsp  like so:

<sjg:gridColumn name="country" index="country" title="Country" editable="true" edittype="select" editoptions="{value:'1:101;2:102;101:ABC'}" sortable="false" search="false" width="100"/>

Then in CustomerDAO buildList() ensure that you put in place of the countries only the values 101 or 102 or ABC

If a Row contains a value 101 when you select the row, the default value in the country select list is ABC! Instead it should select by default 101.

Any ideas how I can fix this asap on 3.2.0?

Appreciate any immedte help...Thanks Johannes
Reply all
Reply to author
Forward
0 new messages