我在两个表asset和asset_history中保存值。在创建资产时,如果有任何更新我希望将其存储在asset和asset_history中,我将值保存在资产表中。现在我想在编辑页面中获取两个表值以获取asset_history 我使用sql查询来获取asset_history中的值。所有工作都很好,但它出现在数组列表值中(所有更新列表都显示在单行中)。当我更新了编辑页面中的值,它应该保存并显示在asset_history的不同行中。为此,我使用了 for 循环,但它没有获取值。
资产表我有这些字段:-
id
asset_title
asset_description
client_id
comment
status
etc...
在asset_history 字段中:-
id
comment
update_on
update_by
status
如果资产字段有任何更新。更新列表应该保存在资产和资产历史中。我使用查询来更新(如下所示)。但它正在asset_history 表中获取arraylist。
编辑动作
def dataSource
def edit={
def assetInstance = Asset.get(params.id)
if (!assetInstance) {
flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'asset.label', default: 'Asset'), params.id])}"
redirect(action: "list")
}
else { Sql sql = new Sql(dataSource)
def result = sql.rows("SELECT * from asset_history where id ='"+params.id+"' ")
//def n=result
/* def arr = (String[])result
for(i in 0 .. result.size()-1)
{
return [assetInstance: assetInstance,result:i]
}*/
return [assetInstance: assetInstance,result: result]
}
}
在edit.gsp
<tbody>
<tr>
<td>${result.id}</br></td>
<td>${result.comment}</br></td>
<td>${result.update_on}</br></td>
<td>${result.update_time}</br></td>
<td>${result.update_by}</br></td>
</tr>
</tbody>
在asset_history表中,值在arraylist中并在单行中显示更新的列表。但是我想在单独的行中显示它,当我每次更新时。我为此使用了for循环,但它不起作用。请指导我解决这个问题。