Wijmo provides a WjFlexGridCellTemplate directive for Angular 2 that allows you to define a template for any type of FlexGrid cell.
This example shows a FlexGrid that includes all of the cell types available, and allows you to selectively apply specific cell templates to the control. Each template applies to every cell of its specified type within the control. Clear a checkbox to see the template removed from all instances of that cell type.
Note that in order to see the change for the CellEdit cell type, you must first double-click inside a cell to put it in edit mode. To see the change for the RowHeaderEdit cell type, put any cell into edit mode, and look at the RowHeader cell for that row.
{{item.country}}
This sample demonstrates cell templates with conditional content controlled by the Angular 2 ngIf directive. It is based on the same CollectionView data source as the previous example, grouped on the Country column, but this one appears like a summary report. It shows only group rows with a white background. (The background color is set in the CSS tab.) There are no visible detail rows in this grid.
The first Country column shows GroupHeader cells that are customized to show country flags. The Downloads
column shows Group cells with a nested WjFlexGrid or WjFlexChart components bound to the group’s child
items ([itemsSource]="item.items"). This allows us to show statistical data for the group,
either as a chart or as a table. The customized Downloads column’s template adds a ComboBox that allows the user
to choose how to represent the data.
The ngIf attribute on the WjFlexGrid and WjFlexChart components is bound to the value selected in the ComboBox, and controls which one appears in the group cell.
{{item.name}}
This example is a variation of the previous example, but the inclusion and settings of statistical data columns in this grid is defined as an array in the component. The wj-flex-grid-column component is bound to this array via the Angular 2 ngFor directive. Each column settings object includes columnHeaderTemplate and groupTemplate properties containing template component for the cells.
This content is included in the wjFlexGridCellTemplate directives using the wj-component-loader component.
Each column settings object also has an isAvailable property indicating whether the column is included in the FlexGrid. The inclusion is controlled by the ngIf directive on the wj-flex-grid-column component. You can change this value for each column settings object using the Wijmo ListBox control with checkboxes, which is bound to the column settings array.
The Country column is defined statically in the markup, and uses the CountryGroupHeaderTemplate component as its GroupHeader cell template.