aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 138 forks source link

Use filter for template ‘tmpl” to use to render cells in a column #449

Open samurai-jack opened 7 years ago

samurai-jack commented 7 years ago

Hello. One of the information contained in the data collection is the "ID" of the user who writes the data to the data collection. Using the code: {key: 'osobaKolegiumId', label: 'Uczestnik kolegium', tmpl: Template._userUczestniczacyKolegium}

Displaying the value of the template "_userUczestniczacyKolegium"

The problem is that the built-in filter package "Reactive Table" does not filter data on the basis of the information contained in the template "_userUczestniczacyKolegium"

html file: <template name="_userUczestniczacyKolegium"> {{author}} </template>

js file:

import { Meteor } from meteor/meteor;
import { Template } from meteor/templating;

import ./_user-uczestniczacy-kolegium.html;

Template._userUczestniczacyKolegium.onCreated( () => {
  Template.instance().subscribe( 'usersProfile' );
});

Template._userUczestniczacyKolegium.helpers({
  author: function () {
    var osobaKolegiumId = Meteor.users.findOne({ _id: this.osobaKolegiumId });
    return osobaKolegiumId.username;
  }
});
aslagle commented 7 years ago

You're right, this package can only filter on data in the original collection. You'd have to change your data so that the username is in the user profile if you want to filter based on that.