【问题标题】:Ng2-smart-table - Angular 2 - Columns and same nameNg2-smart-table - Angular 2 - 列和同名
【发布时间】:2017-07-20 10:13:03
【问题描述】:

以下是我的表格的列,我只得到了这部分代码

           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;
                    })
            }

大家好!我就是上述情况。我需要从“产品”键开始的 json 中获取数据。问题是 ng2 智能表不允许具有相同名称的列。然后,我尝试用“product.variantList”重命名第二列,但代码不接受名称中的点。有什么解决办法吗?谢谢

【问题讨论】:

  • 您找到解决方案了吗?

标签: javascript json angular typescript ng2-smart-table


【解决方案1】:

如果在键中使用破折号(“-”),则代码中断时会报告类似的问题。当键中出现点(“。”)时,将应用相同的解决方案。

参考-Reading out JSON using JavaScript

【讨论】:

  • 试过这个但是代码不喜欢看​​到相同的键,如果我把嵌套代码放在[]里面也没关系,比如['nestedcode']
猜你喜欢
  • 2020-01-03
  • 1970-01-01
  • 2020-07-08
  • 1970-01-01
  • 1970-01-01
  • 2019-01-08
  • 2019-04-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多