Class IgxColumnComponent

Ignite UI for Angular Column - Documentation

The Ignite UI Column is used within an igx-grid element to define what data the column will show. Features such as sorting, filtering & editing are enabled at the column level. You can also provide a template containing custom content inside the column using ng-template which will be used for all cells within the column.

Hierarchy

Implements

  • AfterContentInit
  • OnDestroy
  • ColumnType

Index

Constructors

  • new IgxColumnComponent(grid: GridType, cdr: ChangeDetectorRef, platform: PlatformUtil): IgxColumnComponent

Properties

additionalTemplateContext: any

Sets/gets custom properties provided in additional template context.

<igx-column [additionalTemplateContext]="contextObject">
<ng-template igxCell let-cell="cell" let-props="additionalTemplateContext">
{{ props }}
</ng-template>
</igx-column>
memberof

IgxColumnComponent

autosizeHeader: boolean = true

Sets/gets whether the column header is included in autosize logic. Useful when template for a column header is sized based on parent, for example a default div. Default value is false.

let isResizable = this.column.resizable;
<igx-column [resizable] = "true"></igx-column>
memberof

IgxColumnComponent

calcPixelWidth: number
cdr: ChangeDetectorRef
cellClasses: any

Sets a conditional class selector of the column cells. Accepts an object literal, containing key-value pairs, where the key is the name of the CSS class, while the value is either a callback function that returns a boolean, or boolean, like so:

callback = (rowData, columnKey, cellValue, rowIndex) => { return rowData[columnKey] > 6; }
cellClasses = { 'className' : this.callback };
<igx-column [cellClasses] = "cellClasses"></igx-column>
<igx-column [cellClasses] = "{'class1' : true }"></igx-column>
memberof

IgxColumnComponent

cellStyles: any = null

Sets conditional style properties on the column cells. Similar to ngStyle it accepts an object literal where the keys are the style properties and the value is the expression to be evaluated. As with cellClasses it accepts a callback function.

styles = {
background: 'royalblue',
color: (rowData, columnKey, cellValue, rowIndex) => value.startsWith('Important') ? 'red': 'inherit'
}
<igx-column [cellStyles]="styles"></igx-column>
memberof

IgxColumnComponent

children: QueryList<IgxColumnComponent>

Sets/gets the children columns.

let columnChildren = this.column.children;
this.column.children = childrenColumns;
memberof

IgxColumnComponent

colEnd: number

Column index where the current field should end. The amount of columns between colStart and colEnd will determine the amount of spanning columns to that field

<igx-column-layout>
<igx-column [colEnd]="3" [rowStart]="1" [colStart]="1"></igx-column>
</igx-column-layout>
memberof

IgxColumnComponent

colStart: number

Column index from which the field is starting.

<igx-column-layout>
<igx-column [colStart]="1" [rowStart]="1"></igx-column>
</igx-column-layout>
memberof

IgxColumnComponent

dataType: GridColumnDataType = GridColumnDataType.String

Sets/gets the data type of the column values. Default value is string.

let columnDataType = this.column.dataType;
<igx-column [dataType] = "'number'"></igx-column>
memberof

IgxColumnComponent

defaultWidth: string

hidden

disableHiding: boolean = false

Gets whether the hiding is disabled.

let isHidingDisabled =  this.column.disableHiding;
memberof

IgxColumnComponent

disablePinning: boolean = false

Gets whether the pinning is disabled.

let isPinningDisabled =  this.column.disablePinning;
memberof

IgxColumnComponent

filterable: boolean = true

Sets/gets whether the column is filterable. Default value is true.

let isFilterable = this.column.filterable;
<igx-column [filterable] = "false"></igx-column>
memberof

IgxColumnComponent

filteringIgnoreCase: boolean = true

Sets/gets whether the column filtering should be case sensitive. Default value is true.

let filteringIgnoreCase = this.column.filteringIgnoreCase;
<igx-column [filteringIgnoreCase] = "false"></igx-column>
memberof

IgxColumnComponent

formatter: ((value: any, rowData?: any) => any)

Type declaration

    • (value: any, rowData?: any): any
    • Applies display format to cell values in the column. Does not modify the underlying data.

      remark

      Note: As the formatter is used in places like the Excel style filtering dialog, in certain scenarios (remote filtering for example), the row data argument can be undefined.

      In this example, we check to see if the column name is Salary, and then provide a method as the column formatter to format the value into a currency string.

      example
      columnInit(column: IgxColumnComponent) {
      if (column.field == "Salary") {
      column.formatter = (salary => this.format(salary));
      }
      }

      format(value: number) : string {
      return formatCurrency(value, "en-us", "$");
      }
      example
      const column = this.grid.getColumnByName('Address');
      const addressFormatter = (address: string, rowData: any) => data.privacyEnabled ? 'unknown' : address;
      column.formatter = addressFormatter;
      memberof

      IgxColumnComponent

      Parameters

      • value: any
      • Optional rowData: any

      Returns any

grid: GridType
groupable: boolean = false

Sets/gets whether the column is groupable. Default value is false.

let isGroupable = this.column.groupable;
<igx-column [groupable] = "true"></igx-column>
memberof

IgxColumnComponent

header: string = ''

Sets/gets the header value.

let columnHeader = this.column.header;
<igx-column [header] = "'ID'"></igx-column>
memberof

IgxColumnComponent

headerClasses: string = ''

Sets/gets the class selector of the column header.

let columnHeaderClass = this.column.headerClasses;
<igx-column [headerClasses] = "'column-header'"></igx-column>
memberof

IgxColumnComponent

headerGroupClasses: string = ''

Sets/gets the class selector of the column group header.

let columnHeaderClass = this.column.headerGroupClasses;
<igx-column [headerGroupClasses] = "'column-group-header'"></igx-column>
memberof

IgxColumnComponent

headerGroupStyles: any = null

Sets conditional style properties on the column header group wrapper. Similar to ngStyle it accepts an object literal where the keys are the style properties and the value is the expression to be evaluated.

styles = {
background: 'royalblue',
color: (column) => column.pinned ? 'red': 'inherit'
}
<igx-column [headerGroupStyles]="styles"></igx-column>
memberof

IgxColumnComponent

headerStyles: any = null

Sets conditional style properties on the column header. Similar to ngStyle it accepts an object literal where the keys are the style properties and the value is the expression to be evaluated.

styles = {
background: 'royalblue',
color: (column) => column.pinned ? 'red': 'inherit'
}
<igx-column [headerStyles]="styles"></igx-column>
memberof

IgxColumnComponent

maxWidth: string

Sets/gets the maximum width of the column.

let columnMaxWidth = this.column.width;
<igx-column [maxWidth] = "'150px'"></igx-column>
memberof

IgxColumnComponent

movable: boolean = false
deprecated

in version 13.1.0. Use IgxGridComponent.moving instead.

Sets/gets whether the column is movable. Default value is false.

let isMovable = this.column.movable;
<igx-column [movable] = "true"></igx-column>
memberof

IgxColumnComponent

parent: any = null

Sets/gets the parent column.

let parentColumn = this.column.parent;
this.column.parent = higherLevelColumn;
memberof

IgxColumnComponent

resizable: boolean = false

Sets/gets whether the column is resizable. Default value is false.

let isResizable = this.column.resizable;
<igx-column [resizable] = "true"></igx-column>
memberof

IgxColumnComponent

rowEnd: number

Row index where the current field should end. The amount of rows between rowStart and rowEnd will determine the amount of spanning rows to that field

<igx-column-layout>
<igx-column [rowEnd]="2" [rowStart]="1" [colStart]="1"></igx-column>
</igx-column-layout>
memberof

IgxColumnComponent

rowStart: number

Row index from which the field is starting.

<igx-column-layout>
<igx-column [rowStart]="1" [colStart]="1"></igx-column>
</igx-column-layout>
memberof

IgxColumnComponent

searchable: boolean = true

Sets/gets whether the column is searchable. Default value is true.

let isSearchable =  this.column.searchable';
 <igx-column [searchable] = "false"></igx-column>
memberof

IgxColumnComponent

sortable: boolean = false

Sets/gets whether the column is sortable. Default value is false.

let isSortable = this.column.sortable;
<igx-column [sortable] = "true"></igx-column>
memberof

IgxColumnComponent

sortingIgnoreCase: boolean = true

Sets/gets whether the column sorting should be case sensitive. Default value is true.

let sortingIgnoreCase = this.column.sortingIgnoreCase;
<igx-column [sortingIgnoreCase] = "false"></igx-column>
memberof

IgxColumnComponent

summaryFormatter: ((summary: IgxSummaryResult, summaryOperand: IgxSummaryOperand) => any)

Type declaration

    • The summaryFormatter is used to format the display of the column summaries.

      In this example, we check to see if the column name is OrderDate, and then provide a method as the summaryFormatter to change the locale for the dates to 'fr-FR'. The summaries with the count key are skipped so they are displayed as numbers.

      columnInit(column: IgxColumnComponent) {
      if (column.field == "OrderDate") {
      column.summaryFormatter = this.summaryFormat;
      }
      }

      summaryFormat(summary: IgxSummaryResult, summaryOperand: IgxSummaryOperand): string {
      const result = summary.summaryResult;
      if(summaryResult.key !== 'count' && result !== null && result !== undefined) {
      const pipe = new DatePipe('fr-FR');
      return pipe.transform(result,'mediumDate');
      }
      return result;
      }
      memberof

      IgxColumnComponent

      Parameters

      Returns any

title: string = ''

Sets/gets the title value.

let title = this.column.title;
<igx-column [title] = "'Some column tooltip'"></igx-column>
memberof

IgxColumnComponent

widthSetByUser: boolean

hidden

Accessors

  • get bodyTemplate(): TemplateRef<any>
  • set bodyTemplate(template: TemplateRef<any>): void
  • get columnGroup(): boolean
  • get columnLayout(): boolean
  • get columnLayoutChild(): any
  • get defaultMinWidth(): string
  • get editable(): boolean
  • set editable(editable: boolean): void
  • get field(): string
  • set field(value: string): void
  • get filterCell(): IgxGridFilteringCellComponent
  • get filterCellTemplate(): TemplateRef<any>
  • set filterCellTemplate(template: TemplateRef<any>): void
  • Returns a reference to the filterCellTemplate.

    let filterCellTemplate = this.column.filterCellTemplate;
    
    memberof

    IgxColumnComponent

    Returns TemplateRef<any>

  • Sets the quick filter template.

    <ng-template #filterCellTemplate IgxFilterCellTemplate let-column="column">
    <input (input)="onInput()">
    </ng-template>
    @ViewChild("'filterCellTemplate'", {read: TemplateRef })
    public filterCellTemplate: TemplateRef<any>;
    this.column.filterCellTemplate = this.filterCellTemplate;
    memberof

    IgxColumnComponent

    Parameters

    • template: TemplateRef<any>

    Returns void

  • get gridColumnSpan(): number
  • get gridRowSpan(): number
  • get groupingComparer(): ((a: any, b: any) => number)
  • set groupingComparer(funcRef: ((a: any, b: any) => number)): void
  • Gets the function that compares values for grouping.

    let groupingComparer = this.column.groupingComparer'
    
    memberof

    IgxColumnComponent

    Returns ((a: any, b: any) => number)

      • (a: any, b: any): number
      • Gets the function that compares values for grouping.

        let groupingComparer = this.column.groupingComparer'
        
        memberof

        IgxColumnComponent

        Parameters

        • a: any
        • b: any

        Returns number

  • Sets a custom function to compare values for grouping. Subsequent values in the sorted data that the function returns 0 for are grouped.

    this.column.groupingComparer = (a: any, b: any) => { return a === b ? 0 : -1; }
    
    memberof

    IgxColumnComponent

    Parameters

    • funcRef: ((a: any, b: any) => number)
        • (a: any, b: any): number
        • Parameters

          • a: any
          • b: any

          Returns number

    Returns void

  • get hasSummary(): boolean
  • set hasSummary(value: boolean): void
  • get headerCell(): IgxGridHeaderComponent
  • get headerGroup(): IgxGridHeaderGroupComponent
  • get headerTemplate(): TemplateRef<any>
  • set headerTemplate(template: TemplateRef<any>): void
  • Returns a reference to the header template.

    let headerTemplate = this.column.headerTemplate;
    
    memberof

    IgxColumnComponent

    Returns TemplateRef<any>

  • Sets the header template. Note that the column header height is fixed and any content bigger than it will be cut off.

    <ng-template #headerTemplate>
    <div style = "background-color:black" (click) = "changeColor(val)">
    <span style="color:red" >{{column.field}}</span>
    </div>
    </ng-template>
    @ViewChild("'headerTemplate'", {read: TemplateRef })
    public headerTemplate: TemplateRef<any>;
    this.column.headerTemplate = this.headerTemplate;
    memberof

    IgxColumnComponent

    Parameters

    • template: TemplateRef<any>

    Returns void

  • get hidden(): boolean
  • set hidden(value: boolean): void
  • get index(): number
  • get inlineEditorTemplate(): TemplateRef<any>
  • set inlineEditorTemplate(template: TemplateRef<any>): void
  • Returns a reference to the inline editor template.

    let inlineEditorTemplate = this.column.inlineEditorTemplate;
    
    memberof

    IgxColumnComponent

    Returns TemplateRef<any>

  • Sets the inline editor template.

    <ng-template #inlineEditorTemplate igxCellEditor let-cell="cell">
    <input type="string" [(ngModel)]="cell.value"/>
    </ng-template>
    @ViewChild("'inlineEditorTemplate'", {read: TemplateRef })
    public inlineEditorTemplate: TemplateRef<any>;
    this.column.inlineEditorTemplate = this.inlineEditorTemplate;
    memberof

    IgxColumnComponent

    Parameters

    • template: TemplateRef<any>

    Returns void

  • get isFirstPinned(): boolean
  • get isLastPinned(): boolean
  • get level(): number
  • get minWidth(): string
  • set minWidth(value: string): void
  • get pinned(): boolean
  • set pinned(value: boolean): void
  • get rightPinnedOffset(): string
  • get selectable(): boolean
  • set selectable(value: boolean): void
  • get selected(): boolean
  • set selected(value: boolean): void
  • get summaries(): any
  • set summaries(classRef: any): void
  • get summaryTemplate(): TemplateRef<any>
  • set summaryTemplate(template: TemplateRef<any>): void
  • Returns a reference to the summaryTemplate.

    let summaryTemplate = this.column.summaryTemplate;
    
    memberof

    IgxColumnComponent

    Returns TemplateRef<any>

  • Sets the summary template.

    <ng-template #summaryTemplate igxSummary let-summaryResults>
    <p>{{ summaryResults[0].label }}: {{ summaryResults[0].summaryResult }}</p>
    <p>{{ summaryResults[1].label }}: {{ summaryResults[1].summaryResult }}</p>
    </ng-template>
    @ViewChild("'summaryTemplate'", {read: TemplateRef })
    public summaryTemplate: TemplateRef<any>;
    this.column.summaryTemplate = this.summaryTemplate;
    memberof

    IgxColumnComponent

    Parameters

    • template: TemplateRef<any>

    Returns void

  • get topLevelParent(): any
  • get visibleIndex(): number
  • get visibleWhenCollapsed(): boolean
  • set visibleWhenCollapsed(value: boolean): void
  • get width(): string
  • set width(value: string): void

Methods

  • autosize(byHeaderOnly?: boolean): void
  • Autosize the column to the longest currently visible cell value, including the header cell.

    @ViewChild('grid') grid: IgxGridComponent;
    let column = this.grid.columnList.filter(c => c.field === 'ID')[0];
    column.autosize();
    memberof

    IgxColumnComponent

    Parameters

    • byHeaderOnly: boolean = false

      Set if column should be autosized based only on the header content.

    Returns void

  • getResizableColUnderEnd(): MRLResizeColumnInfo[]
  • move(index: number): void
  • Moves a column to the specified visible index. If passed index is invalid, or if column would receive a different visible index after moving, moving is not performed. If passed index would move the column to a different column group. moving is not performed.

    example
    column.move(index);
    
    memberof

    IgxColumnComponent

    Parameters

    • index: number

    Returns void

  • pin(index?: number): boolean
  • Pins the column at the provided index in the pinned area. Defaults to index 0 if not provided, or to the initial index in the pinned area. Returns true if the column is successfully pinned. Returns false if the column cannot be pinned. Column cannot be pinned if:

    • Is already pinned
    • index argument is out of range
    • The pinned area exceeds 80% of the grid width
      let success = this.column.pin();
      
    memberof

    IgxColumnComponent

    Parameters

    • Optional index: number

    Returns boolean

  • unpin(index?: number): boolean
  • Unpins the column and place it at the provided index in the unpinned area. Defaults to index 0 if not provided, or to the initial index in the unpinned area. Returns true if the column is successfully unpinned. Returns false if the column cannot be unpinned. Column cannot be unpinned if:

    • Is already unpinned
    • index argument is out of range
      let success = this.column.unpin();
      
    memberof

    IgxColumnComponent

    Parameters

    • Optional index: number

    Returns boolean