How can i use two collection in single reactive table?

I am using aslagle:reactive-table package for getting data from two collection but its not working. my anyone help me out with using two collection in reactive table.

Example:
I have two collection A and B :
Collection A consist of fields C1, C2, C3
Collection B consist of fields C4, C5 and C6

I want to display C1, C2, C3, C4, C5, C6 in a single table
with all columns sortable and searchable …

Please tell help me for solution or if i can use another package for this

Thanks in advance…:

Multiple collections aren’t supported, but reactive-table does accept arrays for its collection parameter. This means you can combine your collections ahead of time into an array, then have that array passed in the collection param. So something like:

{{> reactiveTable collection=tableValues}}

and in your helper:

Template.someTemplate.helpers({
  tableValues() {
    const collectionA = CollectionA.find().fetch();
    const collectionB = CollectionB.find().fetch();    
    return collectionA.concat(collectionB);
  }
});

Any changes to collectionA / collectionB will cause the returned array to be re-computed, so the table will still be nice and reactive.

2 Likes

is there any simple example of how I can use reactiveTable to display the properties of an object dynamically depenfing on the keys of the Object each time? Or if there is another good option for using a library table for this case