header
Required. An array of objects with header rows configuration
Usage
header: [
{
text?:
string |
((content: {
[key: string]: string | number | null
}) => string),
tooltip?: boolean | object, // true by default
tooltipTemplate?: (
content: {
[key: string]: string | number | null;
value: string;
},
header: IHeader,
column: ICol
) => string | boolean,
align?: "left" | "center" | "right", // "left" by default
colspan?: number,
rowspan?: number,
css?: string,
content?: "inputFilter" | "selectFilter" | "comboFilter" | "dateFilter",
filterConfig?: {
placeholder?: string, // sets an input placeholder for `inputFilter`, `comboFilter` and `dateFilter`
icon?: string, // sets CSS class for the filter icon in `inputFilter` and the calendar icon in `dateFilter`
/* properties of `comboFilter` configuration */
filter?: (item, input: string) => boolean,
multiselection?: boolean, // false by default
readonly?: boolean, // false by default
virtual?: boolean, // true by default
template?: function,
/* properties of `dateFilter` configuration */
asDateObject?: boolean, // false by default
date?: Date | string,
mark?: (date: Date) => string,
disabledDates?: (date: Date) => boolean,
weekStart?: "saturday" | "sunday" | "monday", // "sunday" by default
weekNumbers?: boolean, // false by default
mode?: "calendar" | "year" | "month" | "timepicker", // "calendar" by default
timePicker?: boolean, // false by default
dateFormat?: string, // by default, applies the dateFormat used for the column
timeFormat?: 24 | 12, // 24 by default
thisMonthOnly?: boolean, // false by default
width?: string | number, // "250px" by default
range?: boolean // false by default
},
customFilter?: (
value: string | number | Date | Date[],
match: string | string[] | Date | Date[]
) => boolean,
headerSort?: boolean, // true by default
sortAs?: (cellValue) => string | number,
htmlEnable?: boolean, // false by default
}
];
Parameters
Each header object may include:
| text | (optional) the text of a header or a callback function which is called with the following parameter:
|
| tooltip | (optional) enables/disables the header tooltip, or sets the configuration object with the tooltip settings; true by default. When set as an object, the tooltip config can have the following properties:
|
| tooltipTemplate | (optional) sets a template for the header tooltip. Takes into account the htmlEnable property. The value of the tooltipTemplate property is a callback function which is called with the following parameters:
|
| align | (optional) aligns data in the header: "left" | "center" | "right", "left" by default |
| colspan | (optional) the number of columns in a colspan |
| rowspan | (optional) the number of rows in a rowspan |
| css | (optional) styling to be applied to a header |
| content | (optional) defines the content of the column header, including the filter type. Allows setting one of the predefined filters:
|
| filterConfig | (optional) a configuration object for setting the behavior and appearance of the filter. The set of properties depends on the filter type specified in the content property: - a configuration object for "inputFilter" can contain the following properties:
- a configuration object for "comboFilter" can contain a set of properties:
Main properties:
|
| customFilter | (optional) a callback function that allows defining custom filtering logic. It takes two parameters:
|
| headerSort | (optional) enables/disables sorting by clicking the header, true by default |
| sortAs | (optional) a function that defines the type to sort data as (e.g. string, number, date, etc.) |
| htmlEnable | (optional) false by default. If set to true, allows using and displaying HTML content in a header. If set to false, the content of the header cells will be displayed as a string value |
Example
const grid = new dhx.Grid("grid_container", {
columns: [
{ id: "title", header: [{ text: "Title" }] },
// more columns configuration objects
],
// more options
});
Related article: Configuration
Related sample: Grid. Grouped headers (spans)