Aldeed:tabular help


#1

Hi all,

I’m trying out the aldeed:tabular package but there’s no data coming into the tables. Any ideas?

Here’s my logins.html file:

<head>
    <title>Logins</title>
</head>
<body>
<h1>Logins</h1>
{{> loginButtons}}
{{> loginstemplate}}
</body>

<template name="loginstemplate">
<h1>External users logged in: {{countusers}}; Active: {{countactiveusers}}</h1>

{{> tabular table=TabularTables.Books class="table table-striped table-bordered table-condensed"}}
</template>

Here’s my logins.js file:

import { Template } from 'meteor/templating';

	Logins = new Mongo.Collection('logins');

	if(Meteor.isClient){
		Meteor.subscribe('getlogins');
		Template.loginstemplate.helpers({
			'ready': function () {
				return Template.instance().subscriptionsReady();
			},
			'getlogin': function(){
				return Logins.find({});
			},
			'countusers': function(){
				return Logins.find({"RegisteredAt":{$ne:'N/A'}}).count();
			},
			'countactiveusers': function(){
				return Logins.find().count();
			},
			'registeredatcheck': function(){
				return this.RegisteredAt instanceof Date;
			},
		});

		Template.registerHelper('formatDate', function(date) {
			if (this.RegisteredAt instanceof Date){
	  			return moment.utc(date).format('D MMM YYYY h:mm A');
	  		}
		});	
	}

	if(Meteor.isServer){
		Meteor.publish('getlogins', function(){
			return Logins.find({});
		});
	}

	TabularTables = {};

	TabularTables.Books = new Tabular.Table({
	  name: "Books",
	  collection: 'getlogins',
	  columns: [
	    {data: "Username", title: "Username"},
	    {data: "Firm", title: "Firm"},
	    {data: "RegisteredAt", title: "RegisteredAt"},
	    {data: "Recordtype", title: "Record type"},
	    {
	      tmpl: Meteor.isClient && Template.loginstemplate
	    }
	  ]
	});

#2

In Tabular.Table definition you should use collection object for collection parameter. So in your case it should look like this:

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

If you want to use a custom publication, you can add its name as a pub parameter.