代码之家  ›  专栏  ›  技术社区  ›  Gvs Akhil

如何将所有表数据行逐行转换为.ts文件语言6

  •  0
  • Gvs Akhil  · 技术社区  · 7 年前

    我一直在为数据表使用primerg,我正在为学生和 当我单击Submit时,我应该将所有数据都保存到我的.ts文件中,以检查哪些人在场或缺席。

    我的输出: enter image description here

    <div class="primetable" style="box-shadow: 0 1px 20px 0 rgba(69,90,100,.08);">
          <p-table [value]="student"
              [columns]="cols"
              #dt
              class="primetable"
              [paginator]="true"
              [rows]="10" [style]="{width:'100%'}"
              [autoLayout]="true"
              [rowsPerPageOptions]="[10,15,20,25]">
    
              <ng-template pTemplate="header"
                  let-columns>
                  <tr>
                      <th style="padding: 15px 15px;color: #1e6bb8;background: white"
                          *ngFor="let col of columns">{{col.header}}</th>
                  </tr>
              </ng-template>
              <ng-template pTemplate="body"
                  let-student
                  let-i="rowIndex"
                  >
                  <tr [pSelectableRow]="student">
                      <td >{{i+1}}</td>
                      <td>{{student.regnum}}</td>
                      <td>
                        <p-checkbox name="groupname" value="val1" [(ngModel)]="student.attendance" (click)="attendance($event, student)"></p-checkbox>
                      </td>
                      <td>
                      </td>
                  </tr>
              </ng-template>
              <ng-template pTemplate="footer" let-student>
                  <tr>
                    <td>
                        <button type="submit" style="width: 50%;"
              class="btn btn-2 btn-2g">Submit</button>
                    </td>
                </tr>
            </ng-template>
          </p-table>
      </div>
    

    在这里,我触发了单击复选框的事件,因此我只为选中的学生获取数据,但我需要在.ts文件中将整个表数据作为json数据

    提前谢谢

    1 回复  |  直到 7 年前
        1
  •  0
  •   Manishkumar Bhavnani    7 年前
    <div class="primetable" style="box-shadow: 0 1px 20px 0 rgba(69,90,100,.08);">
      <p-table [value]="student"
          [columns]="cols"
          #dt
          class="primetable"
          [paginator]="true"
          [rows]="10" [style]="{width:'100%'}"
          [autoLayout]="true"
          [rowsPerPageOptions]="[10,15,20,25]">
    
          <ng-template pTemplate="header"
              let-columns>
              <tr>
                  <th style="padding: 15px 15px;color: #1e6bb8;background: white"
                      *ngFor="let col of columns">{{col.header}}</th>
              </tr>
          </ng-template>
          <ng-template pTemplate="body"
              let-student
              let-i="rowIndex"
              >
              <tr [pSelectableRow]="rowstudent">
                  <td >{{i+1}}</td>
                  <td>{{rowstudent.regnum}}</td>
                  <td>
                    <p-checkbox name="groupname" value="val1" [(ngModel)]="rowstudent.attendance" (click)="attendance($event, student)"></p-checkbox>
                  </td>
                  <td>
                  </td>
              </tr>
          </ng-template>
          <ng-template pTemplate="footer" let-student>
              <tr>
                <td>
                    <button type="submit" style="width: 50%;"
          class="btn btn-2 btn-2g">Submit</button>
                </td>
            </tr>
        </ng-template>
      </p-table>
    

    推荐文章