Ширина колонки Wijmo flexgrid угловая2

Я хочу, чтобы ширина столбца Wijmo FlexGrid охватывала всю ширину.

Поскольку я динамически назначаю столбцы, поэтому не могу использовать [width]="'*'"

1 ответ

Присвойте ссылочную переменную шаблона сетке. Например flex1

<wj-flex-grid #flex1 
      [itemsSource]="data">
<wj-flex-grid>

Тогда в ngAfterViewInit обратный вызов настроить ваши столбцы и назначить столбец в вопросе ширины '*'например,

import { Component, ViewChild, AfterViewInit } from '@angular/core';

import { Collection } from 'wijmo/wijmo';
import { FlexGrid } from 'wijmo/wijmo.grid';

@Component({ ... })
export class MyComponent implements AfterViewInit {
  @ViewChild('flex1') protected grid: FlexGrid;
  protected data: any;

  constructor() {
    this.data = new Collection([
      { id: 1, country: 'United States' },
      { id: 2, country: 'Germany' },
    ]);
  }

  public ngAfterViewInit() {
     // Missing part: Set up columns programmatically
     // OP has done this already.

     // Set the column width of the column with binding to the `country` property
     this.grid.columns.getColumn('country').width = '*';
  }
}
Другие вопросы по тегам