我需要帮助:我无法让(Meteor.publish)过滤网页数据并应用用户(所有者)添加的许可。
现在我向您展示我在Coffescript中编写的代码(publish.coffee和使用该软件包的JS for DataTable)(aldeed:tabular - https://atmospherejs.com/aldeed/tabular)
- publish.coffee
醇>
Meteor.publish 'reportPage', ->
userId = @userId
reportpage = Dealers.find('owner': userId)
if Dealers
return reportPage
@ready()
- reportpage.js
醇>
TabularTables ={};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Dealers = new Tabular.Table({
name: "Dealers",
collection: Dealers,
columns:[
{data: "name", title: "Name"},
{data: "p_iva", title: "Partita IVA"},
]
}, {
waitOn: function() {
return [
Meteor.subscribe("reportPage"),
]
},
path: "/reportPage"
});
- reportpage.html
醇>
<template name="reportpage">
{{> tabular table=TabularTables.Dealers class="table table-striped table-bordered table-condensed"}}
</template>
我该如何解决? 请帮我! :(
答案 0 :(得分:0)
尝试使用selector
过滤表格使用的结果。
TabularTables.Dealers = new Tabular.Table({
name: "Dealers",
collection: Dealers,
columns:[
{data: "name", title: "Name"},
{data: "p_iva", title: "Partita IVA"},
],
selector: function (userId) {
if (!!userId) {
return {owner: userId}
}
},
}
答案 1 :(得分:0)
我这样解决了:
Template.reportpage.helpers({
selector () {
if (!!Meteor.userId()) {
return { owner: Meteor.userId() };
}
},
});