meteor-tabular
meteor-tabular copied to clipboard
Filter data for user owner Logged-In, (this.userId)
Hello, @aldeed
I created the same thing (issue #13), but how did he solve it?, I have this problem, in the data i have (example: owner: 4bu9iDhtCDcZ7qJNr).
I applied your solution:
TabularTables ={};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Dealers = new Tabular.Table({
name: "Dealers",
collection: Dealers,
autoWidth: false,
responsive: true,
columns:[
{data: "owner", title: "ID Proprietario"},
{data: "p_iva", title: "Partita IVA"},
{data: "name", title: "Nome"},
],
allow: function (userId, selector) {
if (selector.userId !== userId && selector.userId !== +selector.userId) {
return false; // not allowed to access another user's products
}
}
But it does not work :(
How to use this? {UserId: Meteor.userId ()} in selector attribute?
How can I fix it? Please help me!
Try this
new Tabular.Table({
name: "MyTable",
collection: MyColl,
selector(userId){
return {owner: userId}
},
// rest of table code
}
then in your publication logic
Meteor.publish("someCollection", function(userId){
check(userId, String);
return Credential.find({owner: userId});
});
})