Aldeed:tabular Tabular.Table instance name VS collection name

I’m reading the docs of the aldeed:tabular package
https://github.com/aldeed/meteor-tabular#example

The docs say:

TabularTables = {};

TabularTables.Books = new Tabular.Table({
  name: "Books",
  collection: Books,

They are assuming that a books collection has previously been defined as
in:

Books = new Mongo.Collection("books");

I feel a constraint on the strings that may be used as attributes of the Tabular.Tables object…

I mean, if I try the following change:

TabularTables = {};

TabularTables.xyz = new Tabular.Table({
  name: "Books",
  collection: Books,

I get the following error:

Error: You must pass Tabular.Table instance as the table attribute
    at .<anonymous> (tabular.js:132)
    at view.js:199
    at Function.Template._withTemplateInstanceFunc (template.js:465)
    at view.js:197
    at Object.Blaze._withCurrentView (view.js:538)
    at viewAutorun (view.js:196)
    at Tracker.Computation._compute (tracker.js:311)
    at new Tracker.Computation (tracker.js:201)
    at Object.Tracker.autorun (tracker.js:576)
    at Blaze.View.autorun (view.js:209)

Is this expected behaviour, or am I doing something wrong?

I’m thinking this is related to your template call:

{{> tabular table=TabularTables.Books }}

should be

{{> tabular table=TabularTables.xyz }}

Thanks for your reply @vigorwebsolutions :slight_smile:

My template call does say table=TabularTables.xyz

Can you reproduce this behaviour? Unless I’m mistaken, I can even see it in a super simple hello world app.

Sorry, haven’t used this package much. But take a look at the following. As you can see, if you pair the “name” property with what you pass into the template inclusion tag, you should be able to use any key to extend the TabularTables object.

TabularTables = {};

TabularTables.MyBooksRule = new Tabular.Table({
  name: "XYZ",
  collection: Books,
  columns: [
    {data: "title", title: "Title"},
    {data: "author", title: "Author"},
    {data: "publishedDate", title: "Published"}
  ]
});

{{> tabular table=TabularTables.XYZ}}

yes!

The template inclusion tag needs the “name” property.

Thanks :slight_smile:

Np, sorry for my unresearched guess yesterday =)