Can anyone help me get started with Tabular? I’ve got the code below and trying to add a row but I know I’m missing something. Jquery somehow doesn’t pick up the table. I’m brand new here (to coding). Meteor and these packages are making things much easier than I expected, but I can’t see how to combine the tabular readme with the Datatables instructions. Thanks all.
client/transactions.html
<div>
<button id="addRow">Add new row</button>
</div>
<div>
{{> tabular table=TabularTables.Transactions id="transactions" class="table table-striped table-bordered table-condensed"}}
</div>
client/transactions.js
Template.Transactions.rendered = function () {
var t = Tabular.Transactions;
$('#addRow').on( 'click', function () {
t.row.add( [
'1',
'2',
'3'
] ).draw();
});
};
lib
TabularTables.Transactions = new Tabular.Table({
name: "Transactions",
collection: Transactions,
columns: [
{data: "target", title: "Target"},
{data: "acquirer", title: "Acquirer"},
{data: "enterpriseValue", title: "Enterprise Value"},
{
tmpl: Meteor.isClient && Template.precedentSelectCell
}
]
});
My use case is fairly simple - creating a table and populating it with arrays of financial data selected from collections of either companies or transactions. Then using averages of information in one column to create SVG shapes (mimicking a chart, but with added interactivity). As per the conversation on Autoform here, am I using something too complex? I actually tried just using Datatables itself but had trouble reconciling their instructions with Meteor.