1

我正式使用 kedo grid 和 ngx 来显示数据。

有4个文件。kedo.ts 和 kedo.html 用于自定义模板,component.html 和 component.ts 用于使用模板。我试图尽可能简化代码,但数据仍然未定义。

kedo.ts

<kendo-grid 
[kendoGridBinding]="gridData"
[formlyAttributes]="field">

  <kendo-grid-column 
  *ngFor="let column of columns" 
  [field]="to.columns">
      <ng-template kendoGridHeaderTemplate let-column let-columnIndex="columnIndex">
      <span [class.special]="column.field === 'CompanyName'">  {{column.field}}({{columnIndex}})</span>
      </ng-template>
         <ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
        <span [class.special]="column === 'CompanyName'">  {{dataItem[column]}}</span>
      </ng-template>
  </kendo-grid-column>
</kendo-grid>

kedo.ts

export class DatatableFormComponentKendo extends FieldArrayType implements OnInit { 

}

  private gridData: any[] //= sampleCustomers; if uncoment here in the grid data will be displayed. 
constructor() {
    super(); 
  }

组件.ts

  private gridData: any[] = sampleCustomers;
  public columns: any[] = [{ field: 'ProductName', title: 'Name'}, { }];


  fieldsTable: FormlyFieldConfig[] = [{
    key: 'gridData',
    type: 'datatable-kendo',
    templateOptions: {
      column: [
        { field: 'actions'},
        { field: 'id'},       

      ],
}

组件.html

<form [formGroup]="form" (ngSubmit)="onSubmitForm(data)" class="py-3">
    <formly-form [model]="modelTable" [fields]="fieldsTable" [options]="options" [form]="form">
    </formly-form>
</form>

4

1 回答 1

0

我为formly创建了一个剑道网格和剑道树列表组件,刚刚发布在github上,你可以在github issue上给它一些时间和想法

https://github.com/ngx-formly/ngx-formly/issues/2371

但我认为这个组件可以解决你的问题

于 2020-11-03T12:14:31.823 回答