meteor-tabular
meteor-tabular copied to clipboard
selector parameters
Hi guys,
Thanks for this project! One question, can I use dynamic tables with the same table but using different selector?
What parameters does the selector receive?
TabularTables.ContractCompanies = new Tabular.Table({
name: "ContractCompanies",
collection: Companies,
columns: [
{data: "name", title: "Name"}
],
"paging": false,
"searching": false,
"info": false,
selector(params) {
return { };
}
});
Thanks in advance, Nicholls
You could use Session or ReactiveVar to change params'
@thearabbit thanks for your response, any example to do that?
You could do this in Template
// HTML
{{> tabular table=TabularTables.Books selector=selector...........}}
// JS
Template.myTemplate.onCreated(function(){
this.dataState = new ReactiveVar();
});
Template.myTemplate.helpers({
selector() {
return {author: Template.instance().dataState.get()};
}
});
Template.myTemplate.events({
'change ....'(event, instance){
instance.dataState.set($(.....).val());
}
}
Beautiful! Works like a charm my friend! One question... It's possible to have multiple instances using the same Tabular Table instance but with different data? For example using Blaze.renderWithData =>
var data = row.data();
Blaze.renderWithData(Template.contractCompanies, data, $(row.child()[0]).find('td')[0]);
I have the following selector, but all tables show the same data at same time.
Template.contractCompanies.onCreated(function () {
this.companies = new ReactiveVar(this.data.companies);
});
Template.contractCompanies.helpers({
selector: function(){
var companies = Template.instance().companies.get();
return {
code : { $in: companies || [] }
};
}
});
And the template is:
<template name="contractCompanies">
{{> tabular table=TabularTables.ContractCompanies selector=selector class="table table-striped table-bordered table-condensed"}}
</template>
Regards, Nicholls
not clear, but I thinks that you could use Session instead.
// common
..... = new Tabular.Table({
// other properties...
selector(userId) {
return { documentOwner: Session.get('data') };
}
});
// Template
Template.A.onCreated(function(){
Session.set('data');
});
.........
Template.B.onCreated(function(){
Session.set('data');
});
And then remove session when template destroy.
Doesn't work with session, because all tables are using the same template mmm
could you try
// common
..... = new Tabular.Table({
// other properties...
selector(userId) {
if(Meteor.isClient){
return { documentOwner: Session.get('data') };
}
}
});
@jdnichollsc, to properly handle reactive changes, you might want to use Template.currentData().companies instead of Template.instance().companies.get(), and you don't need the onCreated.
Hi @aldeed, thanks for your help! But using currentData doesn't work :/ All the tables show the same data mmm
Check my code please =>
import { Template } from 'meteor/templating';
import './contractCompanies.html';
Template.contractCompanies.helpers({
selector: function(){
// var companies = Template.instance().companies.get();
var companies = Template.currentData().companies;
return {
code : { $in: companies || [] }
};
}
});
Regards, Nicholls
OK, it's hard to know what the issue is without a link to a small app that reproduces the issue.
Let me create a small example please, thanks for all!
@aldeed For the moment, check the following video please, is very odd => http://www.screencast.com/t/EssGAKcF9tO Thanks in advance, Nicholls
@jdnichollsc Thanks, but we still would not be able to figure this out without a reproduction app.
Hi @aldeed
Sorry for the delay, check the issue and the respective app to reproduce =>

- Project repository (tabular branch) => https://github.com/jdnichollsc/Meteor-Starter-Template/tree/tabular
Thanks in advance, Nicholls