I am trying to use iron:router, aldeed tabular, and reywood:publish_composite. I want to show a list of Building names with their region’s name (2 columns). My table shows up but there is no data.Can anybody spot the problem?
I have a Buildings collection and a Regions collection. Building.region is keyed to Regions._id
Here is my route in /lib.routes.js
Router.route('/buildings', {
name: 'buildings',
template: 'buildings',
onAfterAction: function() {
document.title = "Buildings";
}
});
/server/publish.js
Meteor.publishComposite("tabularBuildings", function(tableName, ids, fields) {
check(tableName, String);
check(ids, Array);
check(fields, Match.Optional(Object));
this.unblock();
return {
find: function() {
this.unblock()
Buildings.find({_id: {$in: ids}}, {fields: fields});
},
children: [
{
find: function(building) {
this.unblock();
return Regions.find({_id: building.region}, {limit: 1, fields: {name: 1}, sort: {_id: 1}});
}
}]
}
});
/common/tables.js
TabularTables = {};
TabularTables.Buildings = new Tabular.Table({
name: "Buildings",
collection: Buildings,
pub: 'tabularBuildings',
responsive: true,
paging: false,
scrollY: 200,
scrollCollapse: true,
bFilter: false,
order: [[0, "asc"]],
columns: [
{data: "name", title: "Building Name"},
{data: "region_name()", title: "Region"}
]
});
in /client/building/building.html
{{> tabular table=TabularTables.Buildings class="table table-striped"}}
UPDATE - I’ve noticed that the footer of the table reads “Showing 1 to 0 of 20 entries”. There are in fact 20 buildings in the Buildings collection.
UPDATE #2 - The footer starts out reading “Showing 0 to 0 of 0 entries”. It is only when I click a column header to sort, that the footer changes to read “Showing 1 to 0 of 20 entries”