Tin*_*iny 5 jsp struts2 struts2-jquery struts2-jquery-grid struts2-jquery-plugin
我正在尝试使用Struts2-jQuery-grid-3.7.0插件在网格列中填充下拉列表,如下所示.
<s:url id="dataURL" action="CategoryList" namespace="/admin_side"/>
<sjg:gridColumn name="subCategory.category.catName"
index="subCategory.category.catName"
edittype="select"
searchtype="select"
formoptions="{label:'Select'}"
surl="%{dataURL}"
editoptions="{dataUrl : '%{dataURL}'}"
editrules="{required: true}"
title="Category" width="200"
sortable="true" search="true"
editable="true" sorttype="text"/>
Run Code Online (Sandbox Code Playgroud)
并且动作CategoryList映射的动作如下.
@Namespace("/admin_side")
@ResultPath("/WEB-INF/content")
@ParentPackage(value="struts-default")
public final class CategoryList extends ActionSupport implements Serializable {
@Autowired
private final transient Service service = null;
private List<Category>categories = new ArrayList<Category>();
private static final long serialVersionUID = 1L;
public List<Category> getCategories() {
return categories;
}
@Action(value = "CategoryList",
results = {
@Result(name = ActionSupport.SUCCESS, location = "Product.jsp"),
@Result(name = ActionSupport.INPUT, location = "Product.jsp")},
interceptorRefs = {
@InterceptorRef(value = "defaultStack", params = {"validation.validateAnnotatedMethodOnly", "true", "validation.excludeMethods", "load"})})
public String load() throws Exception {
System.out.println("load called...");
categories = service.getCatgeoryList();
return ActionSupport.SUCCESS;
}
}
Run Code Online (Sandbox Code Playgroud)
单击网格上的给定编辑链接时,将load()执行该方法,其中从数据库加载类别列表.
但是,网格中的列表在编辑模式下不显示任何内容(单击编辑链接时).我找不到可能证明这种事情的相关例子.
如何填充此下拉列表,特别是如何使用catName属性和值分别使用catId(of Longtype)属性给出此下拉标签(category在列表中有许多其他属性)?
我没有找到相关的例子来映射java.util.List<E>到<sjg:grid>.
subCategory.category.catName是Product实体的嵌套属性.
在这种情况下,即使在填充列表之后,还应该注意该列的显示值是catName(类型String的类别名称).但是,要设置为实例的所选项的值Product应该是catId(类型为Long的类型id),这似乎不可能作为此列的名称subCategory.category.catName.
直观地说,catId(subCategory.category.catId)会被映射到catName(subCategory.category.catName)这是错误的,如果我可以正确地设想好像已经填充了列表一样.
关于与gridColumn财产有关的文件editoptions:
\n\n\n数据地址
\n\n此选项仅对 select 类型的元素有效 - 即 edittype:select 并且应该是获取 select 元素的 AJAX 数据的 URL。数据是通过 AJAX 调用获取的,并且应该是具有所需选项 One\xe2\x80\xa6 的有效 HTML 选择元素。您可以使用选项组。
\n
您的操作必须返回有效select元素。\n这意味着,您的Product.jsp结果需要如下所示:
<%@ taglib prefix="s" uri="/struts-tags"%>\n<s:select list="categories" key="id" value="name"/>\nRun Code Online (Sandbox Code Playgroud)\n\n参考:http ://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules
\n| 归档时间: |
|
| 查看次数: |
2829 次 |
| 最近记录: |