2017-01-30 23 views
1

我需要顯示在ojTable內POJO的字段的值。如何顯示從內部對象中ojTable值與Oracle噴氣

這裏是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> 

在這種情況下我有檔案的對象,並需要在HTML面達到內定位對象的LOCATIONNAME場。 我試過點notaion - > location.locationName但它不起作用。

我也嘗試過自定義渲染/淘汰賽模板,但他們都需要爲每一個領域,我需要證明,這是不通用的,我認爲一個新的JS functinon。

請幫我實現這一點。

在此先感謝。

回答

2

據我瞭解,以顯示和組織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> 

注意,elemnts的順序應該是配合ojTable列的名字的順序。