简体   繁体   English

将网格线添加到primeng p-celleditor表

[英]Add gridlines to primeng p-celleditor table

I have the following primeng table in my html:我的 html 中有以下启动表:

<p-table
  #dt1
  [value]="data"
  styleClass="p-datatable-gridlines"
>
  <ng-template pTemplate="header">
    <tr>
      <ng-container *ngFor="let column of columns"><th>
            {{ column.label }}
          </th>
      </ng-container>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-row>
    <tr>
      <td
        pEditableColumn
        *ngFor="let column of columns"
      >

          <p-cellEditor>
            <ng-template pTemplate="input">
              <input
                pInputText
                class="p-inputtext"
                type="text"
                [(ngModel)]="row[column.field_name]"
              />
            </ng-template>

            <ng-template pTemplate="output">
                {{ row[column.field_name] }}
              </ng-container>
            </ng-template>
          </p-cellEditor>
        </ng-container>
      </td>
    </tr>
  </ng-template>
</p-table>

However, this isn't displaying any gridlines on the table cells.但是,这不会在表格单元格上显示任何网格线。 I have tried the following to make them appear, but they just aren't being shown.我尝试了以下方法使它们出现,但它们只是没有被显示。 Am I missing something?我错过了什么吗? Or can borders not be added to primeng cell editor tables?或者不能在primeng单元格编辑器表中添加边框?

table, th, td {
  border: 1px solid black;
}


.ui-datatable * {
  border: 5px black !important;
}

Using a CSS class is a workaround:使用 CSS class 是一种解决方法:

.nsg-datatable-tr > td {
    padding: 0.571rem 0.857rem;
    border: 1px solid #c8c8c8;
}

I have added a add row in my header that did not have gridlines as follows::我在没有网格线的 header 中添加了一个添加行,如下所示:

    <tr *ngIf='addRowHeaderShow' class='nsg-datatable-tr'>
      <td style='width: 45px;'>&nbsp;</td>
      <td style='width: 120px;'>
        <button pButton type='button' icon='pi pi-check' class='p-button-success' style='margin-right: .5em' (click)='onAddRowSave()'></button>
        <button pButton type='button' icon='pi pi-times' class='p-button-danger' (click)='onAddRowCancel()'></button>
      </td>
      ...
      <td style='width: 65px;'>&nbsp;</td>
    </tr>

nsg prefix is the company initials that I place on custom CSS, so change appropriately. nsg 前缀是我在自定义 CSS 上放置的公司缩写,因此请适当更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM