首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多对一映射和Struts2-jquery-grid

多对一映射和Struts2-jquery-grid
EN

Stack Overflow用户
提问于 2012-08-06 11:26:14
回答 1查看 766关注 0票数 1

我正在查看struts2-jquery-grid的展示。我可以理解如何将我的对象列表发送到grid Model,但在示例中,对象很简单,它没有作为对象的属性。然而,在我的例子中,我的Model类看起来像这样:

代码语言:javascript
复制
public class Student(
 private String first_name;
 private String last_name;
 private Person father;
 private Person mother; // an attribute of another class

 // other attributes, getters and setters

}

在示例中,它们如下所示:

代码语言:javascript
复制
<s:url id="remoteurl" action="jsontable"/>
    <sjg:grid
        id="gridtable"
        caption="Customers Examples"
        dataType="json"
        href="%{remoteurl}"
        pager="true"
        gridModel="gridModel"
        rowList="10,15,20"
        rowNum="15"
        rownumbers="true"
        resizable="true"
        resizableAnimate="true"
        resizableGhost="true"
        resizableHandles="all"
    >
        <sjg:gridColumn name="id" index="id" title="ID" width="30" formatter="integer" sortable="false"/>
        <sjg:gridColumn name="name" index="name" title="Name" width="250" sortable="true"/>
        <sjg:gridColumn name="country" index="country" title="Country" sortable="false"/>
        <sjg:gridColumn name="city" index="city" title="City" sortable="false"/>
        <sjg:gridColumn name="creditLimit" index="creditLimit" title="Credit Limit" align="right" formatter="currency" sortable="false"/>
    </sjg:grid>
  </div>

请告诉我,如何显示父亲和母亲的ID (我数据库中的外键)?另外,有没有可能不提及所有的属性?非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2012-08-06 15:14:35

如果我的想法是正确的,那么您希望显示father属性的Idmother属性的Id。这意味着Person对象具有Id属性。如果这是正确的,你可以这样做;

代码语言:javascript
复制
<sjg:gridColumn name="father.id" index="father.id" title="Father Id" width="250" sortable="true"/>
<sjg:gridColumn name="mother.id" index="mother.id" title="Mother Id" width="250" sortable="true"/>

我想这会解决你的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11822215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档