具有反应性的流星 livestamp-table
meteor livestamp with reactive-table
我有一个使用 livestamp. However, I wish to represent a collection within a reactive-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 }
]
}
但是当我在模板中使用它时,它工作正常。如何在我的反应式 table 中获得 livestamp
的功能?
你可以用 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>
所以我想实际阅读手册会有所帮助....
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>
我有一个使用 livestamp. However, I wish to represent a collection within a reactive-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 }
]
}
但是当我在模板中使用它时,它工作正常。如何在我的反应式 table 中获得 livestamp
的功能?
你可以用 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>
所以我想实际阅读手册会有所帮助....
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>