【发布时间】:2015-01-20 07:03:15
【问题描述】:
这是我的jsp代码。
<s:url id="myEditOptions" action="myEditOptions.action"/>
<sjg:gridColumn name="branch" align="left" index="Branch" id="bnch" title="Branch"
editable="true" onclick="" edittype="select" editoptions="%{myEditOptions}" />
struts.xml 代码
<action name="myEditOptions" class="com.example.action.BranchAction" method="getDynamicBranch">
<result name="success" type="json" ></result>
</action>
此处为动作类代码
public class BranchAction implements Action {
private Map<String, String> branchList = new LinkedHashMap<String, String>();
List<Customer> customerList;
private List<String> brnch;
Struts2ExampleDAO exampleDao ;
private String myEditOptions;
public BranchAction() {
exampleDao = new Struts2ExampleDAOImpl();
customerList = new ArrayList<Customer>();
}
public String getDynamicBranch(){
customerList = exampleDao.getCustomerListData();
brnch = new ArrayList<String>();
for(Customer cust:customerList) {
int i=0;
if(cust.getBranch() != null && cust.getBranch().length() !=0) {
brnch.add(""+i+":"+cust.getBranch());
}
i++;
}
//Collections.sort(brnch);
myEditOptions = "{value:'"+StringUtils.join(brnch,";")+"'}";
System.out.println("************List size:::********"+brnch.size());
return "success";
}
public String getMyEditOptions() {
return myEditOptions;
}
public void setMyEditOptions(String myEditOptions) {
this.myEditOptions = myEditOptions;
}
}
分支下拉列表未显示。如果有人知道,请帮助我在使用 struts2 jquery jqgrid 进行网格编辑时获取动态下拉列表。即使我可以通过使用普通的 struts2 选择选项来获得动态下拉列表
<s:select label="What's your favor search engine"
headerKey="-1" headerValue="Select Search Engines"
list="searchEngine"
name="yourSearchEngine" />
像这样我在执行 struts2 网格编辑选择选项时需要相同的功能(动态下拉列表)
【问题讨论】:
标签: jquery struts2 jqgrid grid