Angular Gantt - columns
An array of columns in the Gantt.
The columns property accepts an array of columns. To configure a column, use a dxGanttColumn object or specify a data source field (as a string value) to which the column is bound.
- <dx-gantt>
- <dxi-gantt-column dataField="title" caption="Subject" [width]="300"></dxi-gantt-column>
- <dxi-gantt-column dataField="start" caption="Start Date"></dxi-gantt-column>
- <dxi-gantt-column dataField="end" caption="End Date"></dxi-gantt-column>
- </dx-gantt>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- // ...
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- @NgModule({
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- declarations: [AppComponent],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
alignment
Aligns the content of the column.
The default alignment of the content depends on the type of data.
| dataType | alignment |
|---|---|
| 'number' | 'right' |
| 'boolean' | 'center' |
| 'string' | 'left' |
| 'date' | 'left' |
| 'datetime' | 'left' |
allowFiltering
Specifies whether data can be filtered by this column. Applies only if filterRow.visible is true.
See Also
- columns[].allowHeaderFiltering
allowHeaderFiltering
Specifies whether the header filter can be used to filter data by this column. Applies only if headerFilter.visible is true. By default, inherits the value of the allowFiltering property.
allowSorting
Specifies whether a user can sort rows by this column at runtime. Applies only if sorting.mode differs from "none".
calculateCellValue
Calculates custom cell values. Use this function to create an unbound data column.
The data of the row to which the cell belongs.
The this keyword refers to the column's configuration.
A cell's custom value.
Unlike data columns bound to a data field, unbound columns display custom values returned from the calculateCellValue function. The component executes this function multiple times for each record: when records are rendered, when users sort or filter them, and when summaries are computed. To avoid errors and enhance the UI component performance, make sure that properties of the rowData object used in calculation exist and keep calculations inside this function as simple as possible.
In the following code, the calculateCellValue function is used to create an unbound column that displays a calculated sales amount. Data objects contain the Price and UnitsSold fields used in the calculation:
- <dx-gantt
- [dataSource]="products">
- <dxi-gantt-column
- caption="Sales Amount"
- [calculateCellValue]="calculateSalesAmount">
- </dxi-gantt-column>
- </dx-gantt>
- import { Component } from '@angular/core';
- import { Product, Service } from './app.service';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- products: Product[];
- constructor(service: Service) {
- this.products = service.getProducts();
- }
- calculateSalesAmount(rowData) {
- return rowData.Price * rowData.UnitsSold;
- }
- }
- import { Injectable } from '@angular/core';
- export class Product {
- ProductID: number,
- ProductName: string,
- Price: number,
- UnitsSold: number
- }
- let products: Product[] = [{
- ProductID: 1,
- ProductName: "Fabrikam SLR Camera 35\" X358 Blue",
- Price: 168,
- UnitsSold: 4
- },
- // ...
- ];
- @Injectable()
- export class Service {
- getProducts(): Product[] {
- return products;
- }
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- import { Service } from './app.service';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [
- Service
- ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
The following features are disabled in an unbound column, but you can enable them as described in this table:
| Feature | Action that enables it |
|---|---|
| Editing | Implement the setCellValue function and specify the name property instead of dataField. |
| Sorting | Set the allowSorting property to true. |
| Filtering | Set the allowFiltering property to true. |
| Searching | Set the allowSearch property to true. |
| Grouping (DataGrid only) | Set the allowGrouping property to true. |
To invoke the default behavior, call the defaultCalculateCellValue function and return its result.
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- calculateCellValue(rowData) {
- // ...
- const column = this as any;
- return column.defaultCalculateCellValue(rowData);
- }
- }
- <dx-gantt ... >
- <dxi-gantt-column ...
- [calculateCellValue]="calculateCellValue">
- </dxi-gantt-column>
- </dx-gantt>
The
thiskeyword refers to the column's configuration.calculateCellValue is a getter. If you implement the getCombinedFilter(returnDataField) method, pass
falseto the returnDataField parameter. Alternatively, use getCombinedFilter() instead.
See Also
- columns[].customizeText
- columns[].calculateDisplayValue
calculateDisplayValue
Calculates custom display values for column cells. Requires specifying the dataField or calculateCellValue property. Used in lookup optimization.
The data of the row to which the cell belongs.
The this keyword refers to the column's configuration.
The value for the cell to display.
This property accepts the name of the data source field that provides display values...
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="countryID" <!-- provides values for editing -->
- calculateDisplayValue="country"> <!-- provides display values -->
- </dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- // ...
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
... or a function that combines display values. Specify this function only if all data processing operations are executed on the client.
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="countryID" <!-- provides values for editing -->
- [calculateDisplayValue]="getCountryWithCapital"> <!-- combines display values -->
- </dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- getCountryWithCapital(rowData) {
- return rowData.capital + " (" + rowData.country + ")";
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
The UI component uses the specified display values in sorting, searching, and grouping (in case of DataGrid).
Do not use this property to format text in cells. Instead, use the format, customizeText, or cellTemplate property.
calculateFilterExpression
Specifies the column's custom rules to filter data.
A user input value.
Contains an array if the selectedFilterOperation is one of the following: "between", "anyof", "noneof".
A selected filter operation.
A UI element used to filter data.
Possible values: "filterRow", "headerFilter", "filterBuilder", "search".
The this keyword refers to the column's configuration.
A filter expression.
The calculateFilterExpression function should return a filter expression. A basic filter expression has the following format:
- [selector, comparisonOperator, filterValue]
selector
A dataField or function that accepts arowDataproperty and returns column values. Passthis.calculateCellValueif your column contains calculated values.comparisonOperator
One of the following operators: "=", "<>", ">", ">=", "<", "<=", "startswith", "endswith", "contains", "notcontains".filterValue
A user input value. Values from theselectorare compared to this value.
A filter expression for the "between" operation has a different format:
- [ [selector, ">=", startValue], "and", [selector, "<=", endValue] ]
The default "between" implementation is inclusive (filter results include the boundary values). In the following code, the calculateFilterExpression function implements an exclusive "between" operation:
- import { DxGanttModule } from "devextreme-angular";
- import { Column } from 'devextreme/ui/data_grid';
- // ...
- export class AppComponent {
- calculateFilterExpression (this: Column, filterValue, selectedFilterOperation, target) {
- // Override implementation for the "between" filter operation
- if (selectedFilterOperation === "between" && Array.isArray(filterValue)) {
- const filterExpression = [
- [this.dataField, ">", filterValue[0]],
- "and",
- [this.dataField, "<", filterValue[1]]
- ];
- return filterExpression;
- }
- // Invoke the default implementation for other filter operations
- if(!this.defaultCalculateFilterExpression)Â
- return [this.dataField, 'contains', filterValue];Â Â
- return this.defaultCalculateFilterExpression.apply(this, arguments);
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
- <dx-gantt ... >
- <dxi-gantt-column ...
- [calculateFilterExpression]="calculateFilterExpression">
- </dxi-gantt-column>
- </dx-gantt>
To specify a function as a selector, return a property from the rowData object. You can utilize custom logic in the function to implement advanced filtering behavior. The following code snippet returns data from ColumnTwo when users filter ColumnOne data in the DataGrid filterRow:
- import { DxGanttModule } from "devextreme-angular";
- import { Column } from 'devextreme/ui/data_grid';
- // ...
- export class AppComponent {
- calculateFilterExpression (filterValue, selectedFilterOperation, target) {
- if (target === "filterRow") {
- return [(rowData) => {
- return rowData.ColumnTwo
- }, selectedFilterOperation, filterValue];
- }
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
- <dx-gantt ... >
- <dxi-gantt-column ...
- dataField="ColumnOne"
- [calculateFilterExpression]="calculateFilterExpression">
- </dxi-gantt-column>
- </dx-gantt>
You can also implement a function with custom filter conditions as a filter expression. Specify a function that takes an object and returns a Boolean value. The return Boolean represents whether the passed object meets your filtering conditions. The following code snippet returns ColumnOne items that are equal to the ColumnTwo item in the same row when users search for =:
- import { DxGanttModule } from "devextreme-angular";
- import { Column } from 'devextreme/ui/data_grid';
- // ...
- export class AppComponent {
- calculateFilterExpression (filterValue, selectedFilterOperation, target) {
- if (filterValue === "=") {
- return (rowData) => {
- return rowData.ColumnTwo === rowData.ColumnOne;
- };
- }
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
- <dx-gantt ... >
- <dxi-gantt-column ...
- dataField="ColumnOne"
- [calculateFilterExpression]="calculateFilterExpression">
- </dxi-gantt-column>
- </dx-gantt>
- If you specify a custom header filter data source, a header filter item's
valuefield can contain a single value (for example, 0) or a filter expression. If it is a filter expression, the calculateFilterExpression function does not apply. - If users filter data with the component's search panel, the selectedFilterOperation parameter returns
null.
If you use the search panel, the DataGrid may invoke the calculateFilterExpression function multiple times for lookup columns. The first call is to filter the lookup's data source, and subsequent calls are to filter the DataGrid's data source.
DataGrid uses "anyof" and "noneof" filter values for headerFilter. If you specify calculateFilterExpression for headerFilter, return an array of filterExpressions:
- import { DxGanttModule } from "devextreme-angular";
- import { Column } from 'devextreme/ui/data_grid';
- // ...
- export class AppComponent {
- calculateFilterExpression(this: Column, filterValue, selectedFilterOperation, target){
- if (target == "headerFilter") {
- // ...
- let filterExpression = ["myDataField", "contains", customValue];
- return [filterExpression];
- }
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
- <dx-gantt ... >
- <dxi-gantt-column ...
- [calculateFilterExpression]="calculateFilterExpression">
- </dxi-gantt-column>
- </dx-gantt>
See Also
- filterValue
- columns[].filterValue
- columns[].selectedFilterOperation
- columns[].filterValues
- columns[].filterType
- columns[].filterOperations
calculateSortValue
Calculates custom values used to sort this column.
The data of the row to which the cell belongs.
The this keyword refers to the column's configuration.
The value to be used in sorting.
This property accepts the name of the data source field that provides values used to sort this column.
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="Position" <!-- provides column values -->
- calculateSortValue="isOnVacation"> <!-- provides values used to sort the Position column -->
- </dxi-gantt-column>
- </dx-gantt>
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxDataGridModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxDataGridModule
- ],
- providers: [ ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
... or a function that returns such values. In the code below, calculateSortValue concatenates the State and City column values to sort the Employee column:
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="Employee"
- sortOrder="asc"
- [calculateSortValue]="sortByLocation">
- </dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- sortByLocation (rowData) {
- return rowData.State + rowData.City;
- }
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxDataGridModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxDataGridModule
- ],
- providers: [ ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
calculateSortValue does not affect DataGrid group rows. To sort them, implement calculateGroupValue in addition to calculateSortValue. You should also define the groupCellTemplate to apply a custom template for group rows.
This property only accepts strings if remote operations are enabled.
See Also
- sortingMethod
- columns[].sortOrder
caption
Specifies a caption for the column.
Use this property to display a descriptive or friendly name for the column. If this property is not set, the caption will be generated from the name of the dataField.
cellTemplate
Specifies a custom template for data cells.
| Name | Type | Description |
|---|---|---|
| column | Column properties. | |
| columnIndex | Cell column index. | |
| component | UI component instance. | |
| data | Data of the row that contains the cell. | |
| displayValue | any | Cell display value. Differs from the value field only when the column uses lookup or calculateDisplayValue. |
| oldValue | any | |
| row | Cell row. | |
| rowIndex | Cell row index. Begins with 0 on each page. | |
| rowType | Row type. | |
| text | displayValue after applying format and customizeText. | |
| value | any | The cell's raw value. |
| watch | Allows you to track a variable and respond to value changes. Applies when repaintChangesOnly is true.
|
Column properties.
Cell column index.
UI component instance.
Data of the row that contains the cell.
Cell display value. Differs from the value field only when the column uses lookup or calculateDisplayValue.
Cell row.
Cell row index. Begins with 0 on each page.
Refer to Column and Row Indexes for more information.
Row type.
displayValue after applying format and customizeText.
The cell's raw value.
Allows you to track a variable and respond to value changes. Applies when repaintChangesOnly is true.
This function has the following parameters:
getter(data): Function
A function that returns the variable that should be tracked.handler(newValue): Function
A function called when this variable changes.
The following details should be taken into account when you use a cellTemplate:
If you implement two-way data binding in your template, set twoWayBindingEnabled to false to switch off the built-in implementation of this feature.
Template values have no effect on data operations. Implement the column's calculateCellValue or calculateDisplayValue option to transform the cell's underlying value.
cellHintEnabled has no effect for columns where cellTemplate is configured. To display native hints in these columns, add the title attribute to the cellTemplate container element. To display custom hints, configure the DevExtreme Tooltip component. Refer to the following help topic for more information: Customize Cells - Add Tooltips to Cells.
See Also
cssClass
Specifies a CSS class to be applied to the column.
In the following code, this property is assigned a cell-highlighted CSS class that customizes the position column's cell and header styles:
- <dx-gantt ...
- [dataSource]="employees">
- <dxi-gantt-column dataField="ID"></dxi-gantt-column>
- <dxi-gantt-column dataField="position" cssClass="cell-highlighted"></dxi-gantt-column>
- </dx-gantt>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- employees = [{
- ID: 1,
- position: "CTO"
- }, // ...
- ];
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [ ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
- ::ng-deep .dx-data-row .cell-highlighted {
- background-color: #e6e6e6;
- }
- ::ng-deep .dx-header-row .cell-highlighted {
- color: gray;
- font-style: italic;
- }
customizeText
Customizes the text displayed in column cells.
Information on the current cell.
| Name | Type | Description |
|---|---|---|
| valueText | The formatted value converted to a string. | |
| value | | | | The cell's raw value. |
| target | The UI element where the customizeText function was called: "row", "filterRow", or "headerFilter". | |
| groupInterval | | | This parameter is not in effect for the Gantt. |
The formatted value converted to a string.
The cell's raw value.
The UI element where the customizeText function was called: "row", "filterRow", or "headerFilter".
This parameter is not in effect for the Gantt.
The this keyword refers to the column's configuration.
The text the cell should display.
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="Miles"
- [customizeText]="customizeText"
- ></dxi-gantt-column>
- </dx-gantt>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- customizeText(cellInfo) {
- return cellInfo.value + " mi";
- }
- }
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [
- ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
The specified text is not used to filter data. If it should be, specify the calculateCellValue function instead.
The
thiskeyword refers to the column's configuration.
See Also
- columns[].calculateCellValue
dataField
Binds the column to a field of the dataSource.
The following code snippet configures six columns:
- <dx-gantt ... >
- <dxi-gantt-column dataField="CustomerID"></dxi-gantt-column>
- <dxi-gantt-column dataField="EmployeeID" [width]="200"></dxi-gantt-column>
- <dxi-gantt-column dataField="OrderDate"></dxi-gantt-column>
- <dxi-gantt-column dataField="Freight" format="fixedPoint"></dxi-gantt-column>
- <dxi-gantt-column dataField="ShipName"></dxi-gantt-column>
- <dxi-gantt-column dataField="ShipCity"></dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from "devextreme-angular";
- // ...
- @NgModule({
- imports: [
- DxGanttModule
- ],
- })
Review the following notes about data binding:
If you create an unbound column (use the calculateCellValue function), specify the columns[].name property instead of dataField.
Data field names cannot be equal to
thisand should not contain the following characters:.,:,[, and].Column caption is generated from the dataField value. If you want to use a custom caption, specify it in the caption property. Unlike dataField, caption can contain any characters.
See Also
dataType
Casts column values to a specific data type.
If data fields contain values of one type but the UI component requires another, set the correct type in this property. The following code snippet casts the ID and hireDate column values to "number" and "date" types, respectively:
- <dx-gantt ...
- [dataSource]="employees">
- <dxi-gantt-column
- dataField="ID"
- dataType="number">
- </dxi-gantt-column>
- <dxi-gantt-column
- dataField="hireDate"
- dataType="date">
- </dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from 'devextreme-angular';
- // ...
- export class AppComponent {
- employees = [{
- ID: "1",
- hireDate: 1491821760000
- }, // ...
- ];
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
Note the following data type specifics:
"boolean":
- Gantt renders DevExtreme CheckBox components in cells.
"number":
- The component aligns values and captions to the right side of columns.
"object":
- The component implements the toString() method to display fields. To integrate custom display logic, implement columns[].calculateCellValue or calculateDisplayValue.
- Gantt does not generate filterOperations for the filterRow.
- The component's filterBuilder includes only extended filter operations: "anyof", "noneof", "isblank", and "isnotblank".
See Also
encodeHtml
Specifies whether HTML tags are displayed as plain text or applied to the values of the column.
When true, HTML tags are displayed as plain text; when false, they are applied to the values of the column. If you disable this property, malicious code can be executed. Refer to the following help topic for more information: Potentially Vulnerable API - encodeHtml.
falseText
In a boolean column, replaces all false items with a specified text. Applies only if showEditorAlways property is false.
See Also
- columns[].trueText
filterOperations
Specifies available filter operations. Applies if allowFiltering is true and the filterRow is visible.
The following table lists available filter operations by data type. Users can apply these filter operations in the filter row. The Gantt uses the first operation in each array as the default operation for the specified data type.
| dataType | filterOperations |
|---|---|
| "string" | [ "contains", "notcontains", "startswith", "endswith", "=", "<>" ] |
| "numeric" | [ "=", "<>", "<", ">", "<=", ">=", "between" ] |
| "date" | [ "=", "<>", "<", ">", "<=", ">=", "between" ] |
The nested filter builder also allows users to select from an extended set of operations that include "anyof", "noneof", "isblank", "isnotblank", and names of custom operations (if any).
The filterOperations property can also accept an empty array. In this case, the selectedFilterOperation applies, and users cannot change it.
See Also
- columns[].selectedFilterOperation
- columns[].filterValue
filterType
Specifies whether a user changes the current filter by including (selecting) or excluding (clearing the selection of) values. Applies only if headerFilter.visible and allowHeaderFiltering are true.
See Also
- columns[].filterValues
filterValue
Specifies the column's filter value displayed in the filter row.
This value is applied using the selectedFilterOperation.
filterValues
Sets the values in the header filter.
Array<any>
Note: Convert date strings into Date objects before you pass them to the filter expression.
If you specify the headerFilter.groupInterval property, each member of the filterValues array indicates the beginning of a value range:
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="ID"
- dataType="number"
- [filterValues]="[500, 700]"> <!-- Filter intervals are 500-600 and 700-800 -->
- <dxo-gantt-header-filter
- [groupInterval]="100">
- </dxo-gantt-header-filter>
- </dxi-gantt-column>
- </dx-gantt>
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [ ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
See Also
format
Formats a value before it is displayed in a column cell.
See the format section for information on accepted values.
In the following code, the "fixedPoint" format type with a precision of 2 decimal places is applied to column values:
- <dx-gantt ... >
- <dxi-gantt-column ... >
- <dxo-gantt-format
- type="fixedPoint"
- [precision]="2">
- </dxo-gantt-format>
- </dxi-gantt-column>
- </dx-gantt>
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { DxGanttModule } from 'devextreme-angular';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- DxGanttModule
- ],
- providers: [ ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
The format property also limits user input in cells that use the DateBox UI component for editing. For cells that use the NumberBox UI component, you can specify the editorOptions.format property, as shown in the following demo:
headerCellTemplate
Specifies a custom template for column headers.
| Name | Type | Description |
|---|---|---|
| column | The settings of the column to which the header belongs. | |
| columnIndex | The index of the column to which the header belongs. | |
| component | The UI component's instance. |
The settings of the column to which the header belongs.
The index of the column to which the header belongs.
The UI component's instance.
See Also
headerFilter
Specifies data settings for the header filter.
selectedFilterOperation
Specifies a filter operation that applies when users use the filter row to filter the column.
The following table lists default selected filter operations by data type:
| dataType | Default filter operation |
|---|---|
| "string" | "contains" |
| "number" | "=" |
| "date" | "=" |
See Also
sortIndex
Specifies the index according to which columns participate in sorting.
This property accepts an integer specifying the index of the column in a collection of columns with applied sorting. For example, consider the following data source that can provide data for three columns.
- const dataSource = [
- { firstName: "John", lastName: "Doe", title: "Sales Manager" },
- { firstName: "Michael", lastName: "King", title: "Sales Representative" },
- // ...
- ];
To sort data first by the "Last Name" and then by the "First Name" column, use the following code. Note that the sortOrder property should also be specified.
- <dx-gantt ... >
- <dxi-gantt-column dataField="firstName" [sortIndex]="1" sortOrder="asc"></dxi-gantt-column>
- <dxi-gantt-column dataField="lastName" [sortIndex]="0" sortOrder="asc"></dxi-gantt-column>
- </dx-gantt>
- import { DxGanttModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- // ...
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
You can set the sortIndex property at design time to specify initial sorting, or change this property using the columnOption method to sort at runtime.
sortingMethod
Specifies a custom comparison function for sorting. Applies only when sorting is performed on the client.
A value to be compared.
A value to be compared.
The this keyword refers to the column's configuration.
Specifies whether value1 goes before value2.
This function accepts two cell values and should return a number indicating their sort order:
- Less than zero
value1 goes before value2. - Zero
value1 and value2 remain unchanged relative to each other. - Greater than zero
value1 goes after value2.
The string comparison is culture-insensitive by default. Use the following code to make it culture-sensitive:
- import { DxGanttModule } from "devextreme-angular";
- // ...
- export class AppComponent {
- sortStringsConsideringCulture (value1, value2) {
- // Handling null values
- if(!value1 && value2) return -1;
- if(!value1 && !value2) return 0;
- if(value1 && !value2) return 1;
- // Determines whether two strings are equivalent in the current locale
- return value1.localeCompare(value2);
- }
- }
- @NgModule({
- imports: [
- // ...
- DxGanttModule
- ],
- // ...
- })
- <dx-gantt ... >
- <dxi-gantt-column
- dataField="fieldName"
- [sortingMethod]="sortStringsConsideringCulture">
- </dxi-gantt-column>
- </dx-gantt>
sortOrder
Specifies the sort order of column values.
By default, rows are sorted according to the data source. To sort rows in an ascending or descending order, set the sortOrder property to "asc" or "desc". If you need to sort by multiple columns, specify the sortIndex. Otherwise, each sorted column will get a sort index according to its position in the columns array.
See Also
trueText
In a boolean column, replaces all true items with a specified text. Applies only if showEditorAlways property is false.
See Also
- columns[].falseText
visibleIndex
Specifies the position of the column regarding other columns in the resulting UI component.
Visible indexes are normalized after the UI component's creation: the leftmost column is assigned an index of 0; the rightmost column's index becomes equal to the number of visible columns minus 1; other columns get the indexes in between.
See Also
width
Specifies the column's width in pixels or as a percentage. Ignored if it is less than minWidth.
The property supports the following types of values:
- Number
The column's width in pixels. String
A CSS-accepted column width measurement (for example, "55px", "80%" and "auto") except relative units such as em, ch, vh, etc.NOTEFixed columns ignore widths specified as a percentage.