Reactive Table - Show no values


#1

Dear all,

I have a question. I don´t know why the html shows no values. I have many values in the collection: agencies

Here my code:

body.html

<body>
  <div class="container">
    <header>
      <h1>Matrix</h1>
    </header>
    {{> agencies}}
  </div>
</body>

<template name="agencies">
    <div class="container">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Clientes</h3>
            </div>
            <div class="panel-body">
                {{> reactiveTable collection=agencies settings=tableSettings}}
            </div>
        </div>
    </div>
</template>

body.js

import { Agencies } from '../api/agencies.js';

Template.agencies.helpers({
   agencies: function () {
     return Agencies;
   },

   tableSettings : function() {
     return {
         collection: Agencies.find(),
         fields: [
           { key: '_id', label: 'Full Name' },
           { key: 'name', label: 'Score' }
         ]
     };
   },
 });

agencies.js

import { Mongo } from 'meteor/mongo';
export const Agencies = new Mongo.Collection('agencies');

In the html I see the search bar, filter and show 10 rows per page. But I see no data table…

Do you have any idea? THe collection has _id, name as rows.

Thank you for your help.
BR alkru002


#2

have you published the data from the server and subscribed to the data from the client?


#3

I tried to reuse an example. The data from players are inserted by cmd -> meteor mongo -> db.*

I see the names of all players/agencies if I make a list in html.

Do you see my failure?

leaderboard.js

PlayersList = new Mongo.Collection('players');

if(Meteor.isClient){
    Meteor.subscribe('players');
    Template.leaderboard.helpers({
        'players': function(){
            return PlayersList.find({});
        },
        tableSettings : function () {
           return {
               fields: [
                 { key: 'name', label: 'Full Name' },
   
               ]
           };
         }
    });
}

if(Meteor.isServer){
    Meteor.publish('players', function(){
        return PlayersList.find({});
    });
}

leaderboard.html

<head>
    <title>Leaderboard</title>
</head>
<body>
    <h1>Leaderboard</h1>
    {{> leaderboard}}
</body>

<template name="leaderboard">
  <div id="table">
    {{> reactiveTable collection=players settings=tableSettings}}
  </div>
  <div class="leaderboard">
    {{#each players}}
      {{> player}}
    {{/each}}
</div>
</template>

Thank you! Best regards

Alkru002


#4

Just set up a quick reproduction and couldn’t find any problem:

There’s nothing terribly obvious about why the code you’ve posted wouldn’t work.

Though I did notice in your second example that you’re labelling _id as “Full Name” and name as “Score”, which is odd, but not a problem. Also that you’re including a template {{> player }} without posting the code for that template, so my example just spits out the name again


#5

Hey thanks!

I found my mistake but I dont know why it is a mistake.

I imported the data direct over

CMD -> db.players.insert{}…

if I import over your code it works.

But I don´t understand why I cannot use db.players.insert over cmd.

Best regards

alkru002


#6

It could be that ReactiveTable expects the _id field to be a string (default for Meteor), while using the mongo shell defaults to ObjectID as a type?