Search collection array and display in table


#1

Hei all,

I have one question and it could be that you have an idea.

I have a normal reactive table that displays my collection “applications”.

The application collection has this rows:
ID
Name
Short description
person
external agency
departments : [ Department1, Department2, Department3…]

I want to build a table that looks like this

ID | NAME | SHORT | PERSON | External | Department 1 | Department 2 | Department 3|
1 | Test | TEST | ALKRU | ALKRU | X | | X
1 | Test | TEST | ALKRU | ALKRU | X | |

My code is this:

Template.matrix.helpers({
    players: function(){
        return ApplicationList.find({});
    },
    tableSettings : function () {
       return {
           collection: ApplicationList.find({}),
           rowsPerPage: 250,
           showFilter: true,
           fields: [
            { key: 'category_id', label: 'category'},
            { key: 'name', label: 'Application' },
            { key: 'short_description', label: 'Short Description'},
            { key: 'bpo_contacts', label: 'BPO Person'},
            { key: 'external_agency', label: 'External Agency'},
            { key: 'layer_group', label: 'Layer Group'},
            { key: 'business_group', label: 'business_group'},
            { key: '', label: 'Department 1 '},
            { key: '', label: 'Department 2'},
            { key: '', label: 'Department 3'},
            { key: '', label: 'Department 4'},
            { key: '', label: 'Department 5'}
           ]
       };
     }

In the key I need I think a search logic that search in the data departments after the label department 1 and if there is in the array please enter a X or? Is this the right idea to get the table?

Do you know a tutorial where I find an idea about my problem…
Thanks.

Best regards

alkru002