我正在使用带有可编辑选项 true 的 PrimeNg 数据表。我收到以下错误:
错误:
ERROR in Error at D:/Project/ui/src/app/pages/admin/components/dashboard/dashboard.component.html(38,31): ("lumn.isSortab
le" [style]="column.columnStyle?column.columnStyle:{}">
<template [ERROR ->]let-col let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditab")
Error at D:/Project/ui/src/app/pages/admin/components/dashboard/dashboard.component.html(38,39): ("ortable" [style]="colu
mn.columnStyle?column.columnStyle:{}">
<template let-col [ERROR ->]let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditableAsText")
数据表 HTML:
<p-dataTable *ngIf="showTable()" [value]="tableConfig.data" [dataKey]="'id'" [rowStyleClass]="highLightUnsavedRow" [lazy]="true" [rows]="10" [paginator]="true" [responsive]="true" [totalRecords]="getTotalRecords()" (onLazyLoad)="onRowEvent($event)" [(selection)]="selectedRows"
(onRowSelect)="onRowSelect($event)" (onRowUnselect)="onRowUnselect($event)" [editable]="true" (onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)" (selectionChange)="onSelectionChange($event)">
<p-header>Header</p-header>
<p-column *ngIf="tableConfig.isMultiSelect" [style]="tableConfig.multiSelectColStyle?tableConfig.multiSelectColStyle:{'width':'38px'}" selectionMode="multiple"></p-column>
<p-column *ngFor="let column of tableConfig.columns" field="{{column.fieldName}}" header="{{column.columnTitle?column.columnTitle:column.fieldName}}" [filter]="column.isFilterable" [editable]="column.isEditable" [sortable]="column.isSortable" [style]="column.columnStyle?column.columnStyle:{}">
<template let-col let-row="rowData" pTemplate="editor">
<textarea *ngIf="column.isEditableAsText" class="edit-field" [(ngModel)]="row[col.field]" (change)="onTableEditTextBoxChange(row,col.field,row[col.field])"></textarea>
<p-dropdown *ngIf="column.isEditableAsDropDown" class="edit-field" autoWidth="false" [style]="column.editFieldStyle?column.editFieldStyle:{}" [(ngModel)]="row[col.field]" [options]="column.editDropDownOptions"></p-dropdown>
</template>
</p-column>
</p-dataTable>
问题出在以下标签的属性let-col和let-row="rowData"上:
<template let-col let-row="rowData" pTemplate="editor">
如果我删除这两个属性,那么构建问题就会消失,但表格会呈现 0 行。