meteor-tabular icon indicating copy to clipboard operation
meteor-tabular copied to clipboard

Filter data for user owner Logged-In, (this.userId)

Open mOsCpU0 opened this issue 8 years ago • 1 comments

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!

mOsCpU0 avatar Jun 14 '17 09:06 mOsCpU0

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});
  });
})

juliedavila avatar Jun 23 '17 16:06 juliedavila