【问题标题】:how to display row data with respect of columns如何显示关于列的行数据
【发布时间】:2020-08-20 00:22:05
【问题描述】:

我有`

displayColumns = [{name:Id, value: id}{name:Customer, value: Customer},{name:City, value: City},{name:State, value: State},{name:Type, value: Type}]`

行数据是

 userInfoList =[ {
          "Id": 1,
          "Customer": "Ram",
          "City": "Hyderabad",
          "State" : "Andhra",
          "Type" : "Estimation"
        },
        {
          "Id": 2,
          "Customer": "Ramya",
          "City": "Hyderabad",
          "State" : "Andhra",
          "Type" : "Order"
        },
        {
          "Id": 3,
          "Customer": "Ramakrishna",
          "City": "Hyderabad",
          "State" : "Andhra",
          "Type" : "Sales"
        },
        {
          "Id": 4,
          "Customer": "Kishore",
          "City": "Hyderabad",
          "State" : "Andhra",
          "Type" : "Return"
        },
        {
           "Id": 5,
          "Customer": "Anil",
          "City": "Hyderabad",
          "State" : "Andhra",
          "Type" : "Purchange"
        }
     ]

我的表格打印部分 html 是

 <table class="table">
    <thead>
   <tr>
   <th class="text-left" *ngFor = "let column of displayColumns">
   {{column.name}}
     </th>
   </tr>
   </thead>
   <tbody>
   <tr *ngFor="let list of userInfoList; let i=index">
    <td *ngFor="let key of list" > 
     {{list[key]}}
  </td>     
   </tr>
   </tbody>                                    
</table>

听说无法显示关于列的行数据,您能否建议我如何找到它.. 它是打印部分的要求。显示列很好,但无法显示行数据。

【问题讨论】:

    标签: angular bootstrap-4 datatable dynamic-columns datarowview


    【解决方案1】:

    应该这样做

    <table class="table">
        <thead>
       <tr>
       <th>Id</th>
       <th>Customer</th>
       <th>City</th>
       <th>State</th>
       <th>Type</th>
       </tr>
       </thead>
       <tbody>
       <tr *ngFor="let item of userInfoList  | keyvalue; let i=index">
         <td ng-repeat="obj in item"> 
            <b>{{item | json}}</b>
         </td>  
       </tr>
      </tbody>    
    
    
    </table>
    

    【讨论】:

    【解决方案2】:

    我喜欢它现在正在工作

    <tr *ngFor="let list of userInfoList ; let i=index">
     <td *ngFor="let key of list | keyvalue" >                                                                                {{key.value}}
     </td>
    </tr>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-31
      相关资源
      最近更新 更多