我正在使用Struts 2.3.7,struts2-jquery-grid-plugin-3.5.0和hibernate 3.6。我使用一对多映射来连接两个实体。 这些实体
Issue.java
public class Issue implements Serializable
{
private Integer issue_id;
private String issue_description;
private Date issue_raised_date;
private Set<Issue_Tracker> issueTracker = new HashSet<Issue_Tracker>(0);
getter and setters
Issue_Tracker.java
public class Issue_Tracker implements Serializable
{
private Integer issue_id;
private String assignedTo;
如何在 assignedTo 列的jqgrid中显示此数据。我的jqgrid如下:
<sjg:grid
id="gridtable"
caption="Issue-Summary"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="gridModel"
rowList="10,15,20"
rowNum="15"
rownumbers="true"
reloadTopics="reloadGrid"
>
<sjg:gridColumn name="issue_id" id="issueId" index="id" title="Issue-ID" formatter="integer" sortable="false"/>
<sjg:gridColumn name="issue_description" index="id" title="Issue-Details" sortable="false"/>
<sjg:gridColumn name="issue_raised_date" index="date" title="Issue-Date" formatter="date" sortable="false"/>
<sjg:gridColumn name="issueTracker" index="assigned" title="Assigned To" sortable="false"/>
</sjg:grid>
但输出如下,
如何在 assignedTo 列中显示实际数据而不是此对象。
答案 0 :(得分:0)
假设assignedTo不是多个
试试这个
更改
private Set<Issue_Tracker> issueTracker = new HashSet<Issue_Tracker>(0);
要
public IssueTracker issueTracker;
在你的jsp页面中
更改
<sjg:gridColumn name="issueTracker" index="assigned" title="Assigned To" sortable="false"/>
要
<sjg:gridColumn name="issueTracker.assignedTo" index="issueTracker.assigned" title="Assigned To" sortable="false"/>