Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

Custom angular kendo grid component

I try to create a custom angular kendo grid component. Some columns should be created from ContentChildren some classic *ngFor. It's need because some columns it's sample and get from config file. Some page we have column with functionality, example check box. Like this

<kendo-grid
  [data]="dataResult"
  [pageSize]="state.take"
  [skip]="state.skip"
  [sort]="state.sort"
  [filter]="state.filter"
  [sortable]="true"
  [loading]="loading"
  [pageable]="true"
  (dataStateChange)="onDataStateChange($event)"
>
  <ng-template ngFor let-column [ngForOf]="columns">
    <ng-container [ngTemplateOutlet]="column"></ng-container>
  </ng-template>
  <kendo-grid-column
    *ngFor="let field of options.fields"
    [field]="field.id"
    [title]="field.columnName"
    [width]="field.width"
  ></kendo-grid-column>
</kendo-grid>



export class GridComponent implements AfterContentChecked {
  @Input()
  data: any[] = [];

  @Input()
  filters: FilterDescriptor[] = [];

  @Input()
  sorts: SortDescriptor[] = [];

  @Input()
  options: Report = {};

  @ContentChildren(ColumnComponent)
  columns: QueryList<ColumnComponent>;

  dataResult: DataResult;
  state: State;
  loading: boolean;

  constructor() {
    this.state = {
      take: 10,
      skip: 0,
      filter: {
        logic: 'and',
        filters: this.filters
      },
      sort: this.sorts
    };
  }
  ngAfterContentChecked(): void {}

  ngOnInit(): void {}

  onDataStateChange(state: DataStateChangeEvent): void {
    this.state = state;
  }
}

It's possible? Because I get error

TypeError: templateRef.createEmbeddedView is not a function


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...