Populate dropdown list inside Dialog using Struts2 jQuery Plugin

旧街凉风 提交于 2019-12-04 02:00:15

问题


I have a Dialog in which I have to populate a dropdown list from database.I am using struts2-juery-plugins to implement Dialog.This Dialog is open on some event. This is how I create Dialog .

<sj:dialog 
     id="mybuttondialog"
     href="%{fillUser}"
     buttons="{
            'Assign':function() { approoveButton(); },
            'Deny':function() { denyButton(); }
            }"
     autoOpen="false"
     modal="true"
     title="Assign-Task"
     closeTopics="closeThisDialog">
<label>User</label>
  <select id="userCombo" name="userCombo">
    <s:iterator value="userList">
      <option><s:property value="helper_name" /></option>
    </s:iterator>
  </select>    
</sj:dialog>

I am calling an action to fill dropdown list using

<s:url var="fillUser" action="getAllUsers" />

But list is not populating and Dialog got filled with jsonData as following

{"helpDeskUsers":"success","userList":
[{"departments":null,"helper_name":"arvin","helper_value":null,"user_level":null},
{"departments":null,"helper_name":"anand","helper_value":null,"user_level":null},
{"departments":null,"helper_name":"Nehal","helper_value":null,"user_level":null},

Why list is not populating instead whole Dailog is filled with above data. Any help would be great.


回答1:


The <select tag will not work with json list, you should use something like

<s:url var="fillUser" action="getAllUsers" />
<sj:select
  id="userjson"
  name="users"
  href="%{fillUser}"
  list="userList"
  listValue="helper_name"
  listKey="helper_name"


来源:https://stackoverflow.com/questions/14457713/populate-dropdown-list-inside-dialog-using-struts2-jquery-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!