简体   繁体   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
    }
  ]

I have this tabular set up for the meteor using TabularTables. 我使用TabularTables为流星设置了此表格。

In the render function there are val, type and doc. 在render函数中有val,type和doc。 Doc is the information of the whole entry in the database. Doc是数据库中整个条目的信息。 However, if I do not specify it in the columns, it does not return. 但是,如果我没有在列中指定它,则不会返回。 For example I remove the 例如,我删除了

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

portion, the logic in the render if doc.transactionOperation == "Credit" is never true, because doc.transactionOperation is not set. 部分, if doc.transactionOperation == "Credit"永远不为真,则呈现中的逻辑永远不会为真,因为doc.transactionOperation未设置。 Console.log(doc) shows that the object has only the Sum attribute. Console.log(doc)显示该对象仅具有Sum属性。

Is there a way for it to return the full row instead of only the columns specified? 有没有办法返回整行而不是仅返回指定的列?

Take a look at extraFields property. 看一看extraFields属性。 That should work in your case. 这应该在您的情况下有效。

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

By adding fields to extraFields property those get published and you can retrieve from the doc variable in the render function. 通过将字段添加到extraFields属性,这些字段将被发布,您可以从render函数中的doc变量中进行检索。

Here is the official documentation for that. 这是官方文档。
https://github.com/aldeed/meteor-tabular#publishing-extra-fields https://github.com/aldeed/meteor-tabular#publishing-extra-fields

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

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