繁体   English   中英

流星表格中的呼叫行

[英]Calling row in Meteor Tabular

TabularTables.Transactions = new Tabular.Table
  name: "Transactions"
  collection: Transactions
  responsive: true
  columns: [
    {
      data: "transactionOperation"
      title: "Operation"
    }
    {
      data: "sum"
      title: "Sum"
      render: (val, type, doc)->
        if doc.transactionOperation == "Credit"
         return "- " + val
        else
         val
    }
  ]

我使用TabularTables为流星设置了此表格。

在render函数中有val,type和doc。 Doc是数据库中整个条目的信息。 但是,如果我没有在列中指定它,则不会返回。 例如,我删除了

{
      data: "transactionOperation"
      title: "Operation"
    }

部分, if doc.transactionOperation == "Credit"永远不为真,则呈现中的逻辑永远不会为真,因为doc.transactionOperation未设置。 Console.log(doc)显示该对象仅具有Sum属性。

有没有办法返回整行而不是仅返回指定的列?

看一看extraFields属性。 这应该在您的情况下有效。

 TabularTables.Transactions = new Tabular.Table({
  name: "Transactions"
  collection: Transactions
  extraFields: ['transactionOperation']
  /* columns go here
  */
 });

通过将字段添加到extraFields属性,这些字段将被发布,您可以从render函数中的doc变量中进行检索。

这是官方文档。
https://github.com/aldeed/meteor-tabular#publishing-extra-fields

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM