vladblindu
vladblindu

Reputation: 177

Meteor-aldded:tabular collection undefined error

I have the following table which works ok. Beeing an admin account I published the whole Meteor.users collection. I also have two databases in a file in the root /lib

Clients = new Meteor.Collection("client");
Brands = new Meteor.Collection("brand");

They are published for now like this in the /server/lib folder

Meteor.publish("pubClients", function(){
  return Clients.find();
});
Meteor.publish("pubBrands", function(){
  return Brands.find();
});
Meteor.publish("pubUsers", function(){
  return Meteor.users.find();
});

And subscribed like this in the client/lib folder

Meteor.subscribe('pubClients');
Meteor.subscribe('pubBrands');
Meteor.subscribe('pubUsers');

I am using the following template to inject the html: {{> tabular table=TabularTables.Users selector=selector class="table table-striped table-bordered table-condensed"}}

Now if I try to change the Meteor.user to any of the Clients or Brands collection or even inserting above this code a console.log(Clients) I get a: "Clients is not defined" error. If I type in the console > Clients before running rerunning the app it works fine with Mongo.Collection etc. If I run it I get the undefined message in the console too. This is my code ( in fact aldeed's code :) ):

TabularTables = {};

Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);

TabularTables.Users = new Tabular.Table({
name: "UserList",
collection: Meteor.users,
pub:"pubUsers"
columns: [
{data: "username", title: "User name"},
{
  data: "emails",
  title: "Email",
  render: function (val, type, doc) {
    return val[0].main
  }
},
{
  data: "emails",
  title: "verified",
  render: function (val, type, doc) {
    return val[0].verified?"☑":"☐";
  }
},
{
data: "profile",
title: "Account",
render: function (val, type, doc) {
return val.accType;
}
},
{
  data: "profile",
  title: "Active",
  render: function (val, type, doc) {
    return val.active?"active":"pending";
  }
},
{
  data: "createdAt",
  title: "Singned up",
  render: function (val, type, doc) {
    return moment(val).calendar();
  }
},
  {
    tmpl: Meteor.isClient && Template.bookCheckOutCell
  }
]
});

Any ideas?

Thanks a lot.This is my package list:

accounts-base      1.1.3  A user account system

accounts-password  1.0.5  Password support for accounts

aldeed:tabular     0.2.3  Datatables for large or small datasets in Meteor

insecure           1.0.2  Allow all database writes by default

iron:router        1.0.6  Routing specifically designed for Meteor

meteor-platform    1.2.1  Include a standard set of Meteor packages in your app

momentjs:moment    2.9.0  Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging

sergeyt:typeahead  0.10.5_7  Autocomplete package for meteor powered by twitter typeahead.js

twbs:bootstrap     3.3.1_2  Bootstrap (official): the most popular HTML/CSS/JS framework for responsive, mobile first projects

I am using this collection in other points of the app and it works fine. Since I installed the tabular package things got out of hand somehow. I don't have the slights idea were to start from. I am struggling now for two days to get it working, but there's so few information on the web about this package (and most Meteor related subjects) that I decided to post this issue.

Upvotes: 0

Views: 1473

Answers (1)

Sasikanth
Sasikanth

Reputation: 3043

I'm not sure, looks like load order issue

Try writing the tabular code after the initialization of collections in the same file like

in root/lib folder

Clients = new Meteor.Collection("client");
Brands = new Meteor.Collection("brand");


Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);

    TabularTables.Users = new Tabular.Table({
    name: "UserList",
    collection: Meteor.users, //Clientsor Brands
    pub:"pubUsers"
    columns: [
    {data: "username", title: "User name"},
    {
      data: "emails",
      title: "Email",
      render: function (val, type, doc) {
        return val[0].main
      }
    },

Upvotes: 1

Related Questions