对于 angular 中的单个对象,在 table 中显示数据时出现问题

Problem in showing data in a table for single object in angular

我在 angular 中有一个函数:

 memberDtos=[];

    getDataOfDtoCache(cacheData:any,nameOfCache:String){
        console.log(nameOfCache);
        this.hasTableClicked=true;
           this.memberDtos.push(cacheData);
            this.tableName=nameOfCache;
         console.log(this.memberDtos);
      }

同时执行 console.log(this.memberDtos);我得到一个对象作为:

GBIM: false
GBI: false
NCHL_T: false
NCHLST: false
NIB_Q: false
NIBL_S: false
P_RQ: false
PES: false
SQ: false
SBL_RES: false
STLME_REQ: false
STL_IME_RES: false
STLIBL_REQ: false
SN_RES: false
STRVU_REQ: false
SU_RES: false
S_REQ: false
STL_RES: false

我希望这个单个对象进入 table 作为:

但在 html 部分我使用 KendoUI 作为:

   <kendo-grid 
              [kendoGridBinding]="memberDtos" 

              [resizable]="true"
              [filterable]="true"
              [groupable]="true"
              [sortable]="true"
              [pageable]="{
                buttonCount:4,
                pageSizes:[5,10,15]
                }"
              [pageSize]="5"
              *ngIf="hasTableClicked && tableName=='Member DTO'"   >

                  <kendo-grid-column field="memberId" title="Bo Id" width="70">
                  </kendo-grid-column>
                  <kendo-grid-column field="memberCode" title="Client Dealer Id" width="100s">
                  </kendo-grid-column>

              </kendo-grid>

但是在我的 UI 中,我得到了单行的全部数据:

它只是给我看一个单曲 row.I 希望整个数据以不同的方式出现 rows.Can 我明白了吗?

kendoGridBinding 接受数据作为(可迭代的)对象数组。您需要将数据转换为 key: value 对象数组,以便能够像在图像上一样在不同的列中显示值。

这是 working JSFiddle example 它应该是什么样子

for in循环遍历输入数据并将数据推入memberDtos数组作为{ key: value }