mardi 16 octobre 2018

How to build a table with multiple models

I am new to ember and I am trying to figure how to show different model hooks on a component. I have two models that I want to show in a table. Each model should show when the link-to route is clicked, but I want to use one component to build the table like so

let newCol = [];

export default Component.extend({
table:null,
model:null,
columns:computed(()=>{
    return newCol;
}),
init(){
    this._super(...arguments)
    let model = this.get('model')


        for(const key of Object.keys(model[0])){
            newCol.push({'label': key});
            newCol.push({'valuePath': key});
            //console.log(key)
        }

        let table = new Table(this.get('columns'),this.get('model'));
        //console.log('table = ', table);
        this.set('table',table);
}
});

I am passing all my model hook from my routes like this



and my menu is created like this


<li></li>


this creates a menu like user, files when I click the user menu it display the users data on the table but if when I click the files menu then the table doesn't reset to show just the files data. It shows the user and the files data.




Aucun commentaire:

Enregistrer un commentaire