我正在查看struts2-jquery-grid的展示。我可以理解如何将我的对象列表发送到grid Model,但在示例中,对象很简单,它没有作为对象的属性。然而,在我的例子中,我的Model类看起来像这样:
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
}在示例中,它们如下所示:
<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 (我数据库中的外键)?另外,有没有可能不提及所有的属性?非常感谢。
发布于 2012-08-06 15:14:35
如果我的想法是正确的,那么您希望显示father属性的Id和mother属性的Id。这意味着Person对象具有Id属性。如果这是正确的,你可以这样做;
<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"/>我想这会解决你的问题。
https://stackoverflow.com/questions/11822215
复制相似问题