首页 > 解决方案 > 在 OJET 中使用行数据作为列标题创建动态表

问题描述

如何使用子表中的行数据并将其显示为父表上的列数据(一行是标题,下一行是相应数据),同时显示父表中的一些附加数据。

标签: oracle-jet

解决方案


在您的模型和 html 中,您需要遵循相同的内容:

IE:

...
function Model() {
  var self = this;
  self.headersTableCol = ko.observableArray();
  ...
  //In your method to retrieve data parse to JSON
  //Iterate over that and for the first row apply
  //transformation to the follow format in new object:
  var headerJSON = {headerText: json["label"], field: json["field"]}
  headerJSONArray.push(headerJSON);
  ...
  //After loop over columns proceed with this:
  self.headersTableCol(headerJSONArray);
  ...
<oj-table columns='[[headersTableCol]]'></oj-table>  

瞧,这将允许您动态处理列。

我希望有所帮助,问候。


推荐阅读