0

Following are the columns of my table, i got just this part of the code

           products: {
                title: 'Prodotto',
                filter: false,
                class: "colonneTabella",
                width: "15%",
                valuePrepareFunction: (products) => { 
                    var output ="";
                    var outputs = "";
                    products.forEach(function(item){
                        output = item.productDescription

                       /* item.variantList.forEach(function(d){
                           outputs=  d.description;
                        })*/

                    })
                    return output+outputs;


                }
            },
            products: {
                title: 'Variante',
                filter: false,
                class: "colonneTabella",
                width: "20%",
                valuePrepareFunction: (products) => 
                       products.forEach(function(item){
                            item.variantList;
                            item.variantList.forEach(function(d){
                            outputs=  d.description;
                       })
                        return outputs;
                    })
            }

Hi all! I'm in the above situation. I need to get datas from a json starting from the "products" key. The problem is that ng2 smart table doesn't allow columns with the same name. I tried, then, to rename the second column with "product.variantList" but the code doesn't accept dot inside the name. Is there any solution? thanks

Jamil89
  • 165
  • 3
  • 14

1 Answers1

0

There was similar problem reported when code breaks if dash ("-") is used in the key. Same solution will apply when dot (".") appears in the key.

Refer to - Reading out JSON using JavaScript

v.j
  • 186
  • 11
  • Tried this but the codes doesn't like to see the same key, it doesn't matter if I put the nested code inside [] like ['nestedcode'] – Jamil89 Jul 20 '17 at 11:59