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

不自动调整宽度的Ng主表列

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

    我正在使用Ng素数表,当我 栏目>一切正常 但是什么时候 分配了一些宽度,甚至在Inspect中,我找不到任何选项来更改列的宽度。

    enter image description here

    解决方案1: 我试过了

    ::ng-deep .ui-table table {
        table-layout: auto !important;
    }
    

    enter image description here

    输出不令人满意,在右侧留下一些空白。 另外,列值占用的空间不相等,需要一些帮助吗

    解决方案2:我试过了

    <p-table [autoLayout]="true">
    

    与解决方案1相同的输出

    我的HTML代码:

    <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="caption">
                  <div>
                      <input type="text"
                          class="form-control"
                          pInputText
                          size="50"
                          placeholder="Search Data Here"
                          (input)="dt.filterGlobal($event.target.value, 'contains')"
                          style="width:auto">
                  </div>
              </ng-template>
              <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>
                        <input type="checkbox">
                      </td>
                      <td>
                      </td>
                  </tr>
              </ng-template>
          </p-table>
    

    TS代码:

    this.cols = [
          { field: 'S.No', header: 'S.No' },
          { field: 'regnum', header: 'Regnum' },
          { field: 'attendance', header: 'Attendance' }
      ];
    

    提前谢谢,祝你愉快

    0 回复  |  直到 7 年前
    推荐文章