0

livestampを使用した流星アプリがあります。ただし、 react-table内でコレクションを表現したいと考えています。ただし、以下のコードを試しても機能しません (更新された列には何も表示されません)。

Template.sensor_table.helpers
  settings: () ->
    return {
      collection: Sensors
      rowsPerPage: 100
      showFilter: true
      fields: [ 
        { key: '_id', label: 'id' },
        { key: '_id', label: 'rack', fn: (v,o) -> (getSensor v).rack },
        { key: 'temp', label: 'temperature (degC)' },
        { key: 'ts', label: 'updated', fn: (v,o) -> livestamp v }
      ]
    }

しかし、テンプレート内で使用すると正常に動作します。livestampリアクティブ テーブル内の機能を取得するにはどうすればよいですか?

4

2 に答える 2

0

なので、実際にマニュアルを読むと役立つと思います....

Template.sensor_table.helpers
  settings: () ->
    return {
      collection: Sensors
      rowsPerPage: 100
      showFilter: true
      fields: [ 
        { key: '_id', label: 'id' },
        { key: '_id', label: 'rack', fn: (v,o) -> (getSensor v).rack },
        { key: 'temp', label: 'temperature (°C)' },
        { key: 'ts', label: 'updated', tmpl: Template.sensor_updated }
      ]
    }

そして、どこかのテンプレート...

<template name="sensor_updated">
{{ livestamp ts }}
</template>
于 2015-09-23T08:46:11.017 に答える
0

https://atmospherejs.com/aldeed/tabularでそれを行うことができます。これもデータテーブルですが、別のパッケージです (私の意見ではより良い)

ここで使用することを選択した場合は例です。tabular にはフィールドをテンプレートとしてレンダリングするオプションがあり、livestamp はテンプレート自体と同じように機能するはずです。

TabularTables.Books = new Tabular.Table({
  name: "Books",
  collection: Books,
  columns: [
    {data: "_id", title: "id"},
    {data: "_id", title: "Rack"},
    { data: 'ts', title: 'updated',
      tmpl: Meteor.isClient && Template.liveStamp
    }
  ]
});

// template
<template name="liveStamp">
  <p>{{livestamp this.ts}}</p>
</template>
于 2015-09-19T10:16:46.020 に答える