【问题标题】:How to show a value from inner object in ojTable with oracle jet如何使用 oracle jet 在 ojTable 中显示内部对象的值
【发布时间】:2017-01-30 07:19:40
【问题描述】:

我需要在 ojTable 中显示内部 pojo 字段的值。

这里是bakcend代码:

public class Profile implements Serializable {
private String descr;
private Location location;   // I need to show on table -> ojtable
}


public class Location implements Serializable {
private Long id;
private String locationName;
}

还有html代码:

<table id="table" summary="Subscriber List"
data-bind="ojComponent: {component: 'ojTable',
emptyText: 'No Data',
data: dataSource,
selectionMode: {row: 'single'},
columnsDefault: {sortable: 'enabled'},
dnd: {reorder: {columns: 'enabled'}},
columns:
[{headerText: 'Description',
field: 'description'},
{ headerText: 'Location Name',
field: 'location.locationName'}  ----->>>>>> This one is not working
],
rootAttributes: {'style':'width: 100%; height:100%;'}}">
</table>

在这种情况下,我有 Profile 对象,需要在 html 端访问内部 Location 对象的 locationName 字段。 我尝试了 dot notaion -> location.locationName 但它不起作用。

我也尝试了自定义渲染器/敲除模板,但它们都需要一个新的 js 函数用于我需要显示的每个字段,我认为这不是通用的。

请帮助我实现这一目标。

提前致谢。

【问题讨论】:

    标签: javascript html oracle-jet


    【解决方案1】:

    据我了解,显示和组织 ojTable 的最流畅方式是使用自定义行模板,如示例所示:

    <script type="text/html" id="row_tmpl">
    
        <tr>
            <td data-bind="text: location.locationName">
            </td>
            <td data-bind="text: location.id">
            </td>
        </tr>
    
    </script>
    

    请注意,元素的顺序应与 ojTable 列名称的顺序相匹配。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 2018-05-26
      • 1970-01-01
      相关资源
      最近更新 更多