Wijmo flexgrid column width angular2

1.7k Views Asked by At

I want Wijmo FlexGrid column width should cover full width.

As I'm dynamically assigning the columns so can't use [width]="'*'"

1

There are 1 best solutions below

0
On

Assign a template reference variable to the grid. E.g. flex1

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

Then in the ngAfterViewInit callback set up your columns and assign the column in question the width '*', e.g.

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 = '*';
  }
}