Skip to main content

Grid column properties

Usage

columns:[
{
id: string | number,
width?: number, // 100 by default
minWidth?: number, // 20 by default
maxWidth?: number,
autoWidth?: boolean, // false by default
header: [
{
text?: string | ((content: {
[key: string]: string | number | null
}) => string),
tooltip?: boolean | object, // true by default
tooltipTemplate?: (
content: { value: string } & { [key: string]: string | number | null },
header: IHeader,
column: ICol
) => string | boolean,
align?: "left" | "center" | "right", // "left" by default
colspan?: number,
rowspan?: number,
css?: string,
content?: "inputFilter" | "selectFilter" | "comboFilter",
filterConfig?: {
filter?: (item: any, input: string) => boolean,
multiselection?: boolean,
readonly?: boolean,
placeholder?: string,
virtual?: boolean,
template?: function
},
customFilter?: (item: any, input: string) => boolean,
headerSort?: boolean, // true by default
sortAs?: (cellValue: any) => string | number,
htmlEnable?: boolean, // false by default
}
],
footer?: [
{
text?: string | ((content: {
[key: string]: string | number | null
}) => string),
tooltip?: boolean | object, // true by default
tooltipTemplate?: (
content: { value: string } & { [key: string]: string | number | null },
header: IHeader,
column: ICol
) => string | boolean,
align?: "left" | "center" | "right", // "left" by default
colspan?: number,
rowspan?: number,
css?: string,
htmlEnable?: boolean, // false by default
},
],
type?: "string" | "number" | "boolean" | "date", // "string" by default
numberMask?:
| {
prefix?: string, // "" by default (before the value)
suffix?: string, // "" by default (after the value)
groupSeparator?: string, // "," by default
decSeparator?: string, // "." by default
allowNegative?: boolean, // true by default
maxIntLength?: number,
maxDecLength?: number,
minDecLength?: number // 0 by default
}
| boolean,
patternMask?:
| {
pattern: ((value: string | number) => string) | string,
charFormat?: {
[char: string]: RegExp
}
}
| string,
// "input" by default
editorType?: "input" | "select" | "datePicker" | "combobox" | "multiselect" | "textarea",
dateFormat?: string, // "%M %d %Y" by default
options?: (string | { id: string | number, value: string })[] |
(column: object, row?: object) => (string | { id: string | number, value: string })[],
editorConfig?: obj,
adjust?: "data" | "header" | "footer" | boolean, // false by default
align?: "left" | "center" | "right", // "left" by default
htmlEnable?: boolean, // false by default
hidden?: boolean, // false by default
draggable?: boolean, // false by default
editable?: boolean, // false by default
resizable?: boolean, // false by default
sortable?: boolean, // true by default
mark?: { min?: string, max?: string } |
(cell: any, columnCells: any[], row?: object, column?: object) => string,
template?: (cellValue: any, row: object, column: object) => string,
tooltip?: boolean | object, // true by default
tooltipTemplate?: (cellValue: any, row: object, column: object) => string,
groupable?: boolean, // false by default
closable?: boolean, // true by default
summary?: {
[key: string]: string | [string, string] | (row: IRow[]) => string | number
} | string
},
// more column objects
]

Description

id(required) the id of a column
width(optional) the width of a column, 100 by default. Note that width can't be less than 20px.
The property is ignored if the adjust property is used
minWidth(optional) the minimum width to be set for a column, 20 by default

Related Sample: Grid. Columns min width
maxWidth(optional) the maximal width to be set for a column

Related Sample: Grid. Columns max width
autoWidth(optional) enables/disables the ability of a column to adjust its size to the size of Grid, false by default

Also note:
  • If autoWidth is set for a column, the width of the column is calculated on the base of the sizes of the container of the grid and the values of the minWidth/maxWidth properties if they are set for the column.
  • The property is ignored if the adjust property is used.
  • If the width property is specified in the configuration object of a column, the autoWidth property won't work for this column.
  • header(required) an array of objects with header rows configuration. Each header object may include:
    • text - (optional) the text of a header or a callback function which is called with the following parameter:
      • content - an object with the content of the header tooltip that contains the calculated values as key:value pairs, where:
        • the key is either the key defined in the list or the functor name
        • the value can be a string/number or null
        The calculated values are taken either from the summary config option of the component or the summary config option of a column
    • 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:
      • force - (optional) forces opening of a tooltip; if set to true, the showDelay and hideDelay settings are ignored, false by default
      • showDelay - (optional) the time period that should pass before showing a tooltip, in ms
      • hideDelay - (optional) the time period that should pass before hiding a tooltip, in ms
      • margin - (optional) the margin between the node and tooltip; 8px by default
      • position - (optional) the position of a tooltip: "right", "bottom", "center", "left", "top"; "bottom" by default
      • css - (optional) the style of a tooltip box
    • 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:
      • content - an object with the content of the header tooltip. Contains two properties which are available either from the component's or from the column's configuration:
        • value - the value rendered in a cell, including the applied templates
        • an object with the calculated values of the summary property, set as key:value pairs where:
          • the key is either the key defined in the list or the functor name
          • the value can be a string/number or null
      • header - the object of the column header
      • column - the object of a column
      Return false to disable the tooltip
    • 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) additional content of a header, which can be one of the filters: "inputFilter" | "selectFilter" | "comboFilter"
    • filterConfig - (optional) a configuration object for "comboFilter". It can contain a set of properties:
      • filter - (optional) sets a custom function for filtering Combo Box options
      • multiselection - (optional) enables selection of multiple options
      • readonly - (optional) makes ComboBox readonly (it is only possible to select options from the list, without entering words in the input). The default value of the readonly property depends on the following conditions:
        • the readonly:true is set as a default value, if htmlEnable:true is set for a column and there is no template specified for a column
        • in all other cases, readonly:false is set by default
      • placeholder - (optional) sets a placeholder in the input of ComboBox
      • virtual - (optional) enables dynamic loading of data on scrolling the list of options
      • template - (optional) a function which returns a template with content for the filter options. Takes an option item as a parameter:
        • item - (object) an option item
    • customFilter - (optional) a custom function for extended filtering. It takes two parameters:
      • item - (required) a data item the value of which should be compared
      • input - (required) the value of the option selected in the filter
      and returns true/false to specify whether the data item should be displayed in the grid after filtering
    • 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, specifies the HTML content (inner HTML) of a header. If set to false, the content of the header cells will be displayed as a string value

    Related Sample: Grid. Grouped headers (spans)
    footer(optional) an array of objects with footer rows configuration. Each footer object may include:
    • text - (optional) the text of a header or a callback function which is called with the following parameter:
      • content - an object with the content of the footer tooltip that contains the calculated values as key:value pairs, where:
        • the key is either the key defined in the list or the functor name
        • the value can be a string/number or null
        The calculated values are taken either from the summary config option of the component or the summary config option of a column
    • 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:
      • force - (optional) forces opening of a tooltip; if set to true, the showDelay and hideDelay settings are ignored, false by default
      • showDelay - (optional) the time period that should pass before showing a tooltip, in ms
      • hideDelay - (optional) the time period that should pass before hiding a tooltip, in ms
      • margin - (optional) the margin between the node and tooltip; 8px by default
      • position - (optional) the position of a tooltip: "right", "bottom", "center", "left", "top"; "bottom" by default
      • css - (optional) the style of a tooltip box
    • tooltipTemplate - (optional) sets a template for the footer tooltip. Takes into account the htmlEnable property. The value of the tooltipTemplate property is a callback function which is called with the following parameters:
      • content - an object with the content of the footer tooltip. Contains two properties which are available either from the component's or from the column's configuration:
        • value - the value rendered in a cell, including the applied templates
        • an object with the calculated values of the summary property, set as key:value pairs where:
          • the key is either the key defined in the list or the functor name
          • the value can be a string/number or null
      • footer - the object of the column footer
      • column - the object of a column
      Return false to disable the tooltip
    • align - (optional) aligns data in the footer: "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 footer
    • htmlEnable - (optional) false by default. If set to true, specifies the HTML content (inner HTML) of a footer. If set to false, the content of the footer cells will be displayed as a string value

    Related Sample: Grid. Grid with footer
    type(optional) the type of a column. The type sets the alignment of the content and defines the type of the editor used in the column:
    • "string" (the default one) - aligns data to the left side and applies the "input"/"textarea" editor
    • "number" - aligns data to the right side and applies the "input" editor
    • "boolean" - aligns data to the left side and applies the "checkbox" editor
    • "date" - aligns data to the left side and applies the "datePicker" editor
    numberMask(optional) sets an input mask for entering number values. Can be set in two ways:
    • as an object with the following properties:
        - prefix - renders a text before the resulting value
        - suffix - renders a text after the resulting value
        - groupSeparator - sets a separator for thousands
        - decSeparator - sets a separator for decimals
        - allowNegative - allows using negative numbers
        - maxIntLength - allows setting the maximal length of an integer
        - maxDecLength - allows setting the maximal length of a decimal
        - minDecLength - allows setting the minimal rendered length of a decimal
    • as a boolean value converts the number value displayed in the input field into one of the predefined templates
    patternMask(optional) sets an input mask for entering number and string values according to a special pattern. Can be set in two ways:
    • as an object with the following properties:
        - pattern - (function | string) allows specifying the necessary mask and change it dynamically, depending on the entered values. Can be set as:
        • a function that takes as a parameter an entered value specified as a string or as a number and returns a string with a pattern mask
        • a string with a pattern mask
        - charFormat - (object) allows specifying a regular expression for an optional symbol. It is set as an object with key:value pairs, where the key is a symbol and the value is a regular expression
    • as a string allows setting a mask as a string using a predefined set of symbols
    editorType(optional) the type of an editor used in a column: "input" | "select" | "combobox" | "textarea" | "multiselect" | "datePicker", "input" by default
    dateFormat(optional) defines the format of dates. The date format must include delimiters (spaces or symbols), otherwise an error will be thrown
    options(optional) specifies a set of options to be displayed in the editor of a cell. It is required if you specify editorType: "select" | "combobox" | "multiselect". The property can be:
    • an array of string values
    • an array of objects with a set of key:value pairs - attributes of options and their values:
        The id attribute sets the id for the option
        The value attribute sets the value to be displayed both in the editor and in the grid cell. If the id of the option is specified in the data set, the value will also be displayed in the cell on Grid initialization
    • a function which takes two parameters:
        column - (required) an object with the configuration of a column
        row - (optional) an object with all cells in a row
      and must return either an array of string values or an array of objects
    Related Samples:If newOptions property is enabled, all new options will be displayed in the editor regardless of the initialized options.
    editorConfig(optional) an object with configuration settings of the column's editor. The structure of this object depends on the specified type of the editor or the column. Check the list below:

    • editorType: "combobox/multiselect"

      For this type of editor, the editorConfig object can include the following properties:
      • css - (optional) styling to be applied to an option
      • filter - (optional) sets a custom function for filtering combobox options. Takes two parameters:
        • item - (object) an item of data collection
        • target - (string) the string to compare to
        and should return true/false to specify whether an item should be displayed in the filtered list of options
      • eventHandlers - (object) adds event handlers to HTML elements of a custom template of combobox items. Check the details.
      • itemHeight - (optional) the height of an option
      • listHeight - (optional) the height of the list of options
      • newOptions - (optional) allows end users to add new values into the list of combobox options from UI. The new options will also appear in the drop-down list of the header/footer filters (content: "selectFilter" | "comboFilter")
      • placeholder - (optional) sets a placeholder in the editor's input
      • readonly - (optional) makes the editor readonly (it is only possible to select options from the list, without entering words in the input)
      • template - (optional) a callback function which returns a string. It is called with an object argument which contains two properties:
        • id - the id of the selected option
        • value - the value of the selected option

    • editorType: "multiselect"

      For this type of editor, the editorConfig object can include the following properties:
      • selectAllButton - (optional) adds a button that allows selecting all the options in the editor

    • editorType:"datePicker" and column type:"date"

      For this type of editor, the editorConfig object can include the following properties:
      • asDateObject - (optional) sets the date picker mode that presupposes saving a date as a Date object
      and a set of properties of Calendar (except for the value and range ones)

    • editorType:"input" and column type:"number"

      For this combination, the editorConfig object can include the following properties:
      • min - (optional) the minimum allowed value
      • max - (optional) the maximum allowed value

    Related Sample: Grid. Rich example with templates and different editors
    adjust(optional) false by default, defines whether the width of a column is automatically adjusted to its content.

  • The property has a priority over the autoWidth property if it is specified either for the grid or for the column, and over the width property of the column.
  • The width the columns will be adjusted to also depends on the values of the minWidth/maxWidth properties if they are set for a column.
  • align(optional) aligns data in a column: "left" | "center" | "right", "left" by default
    htmlEnable(optional) false by default. If set to true, specifies the HTML content (inner HTML) of a column. If set to false, the content of the column cells will be displayed as a string value

    Related Sample: Grid. Html in data
    hidden(optional) defines whether a column is hidden, false by default

    Related Sample: Grid. Hidden columns
    draggable(optional) defines whether a column is draggable, false by default
    editable(optional) defines whether a column is editable, false by default
    resizable(optional) defines whether a column can be resized, false by default
    sortable(optional) defines whether a column is sortable, true by default
    mark(optional) can be either an object or a function:
    • as an object contains min and max properties, to apply desired CSS classes to cells with minimal|maximal values in a column
    • as a function returns a template for marking a cell(s) and takes several parameters:
      • cell - (required) the value of a cell
      • columnCells - (required) an array of all cell values in the specified column
      • row - (optional) an object with all cells in a row
      • column - (optional) an object with the configuration of a column (see the columns config)

    Related Sample: Grid. Mark cells
    template(optional) a function which returns a template with content for a cell(s). Takes 3 parameters:
    • cellValue - (required) the value of a cell
    • row - (required) an object with all cells in a row
    • column - (required) an object with the configuration of a column (see the columns config)

    Related Sample: Grid. Cell templates
    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:
    • force - (optional) forces opening of a tooltip; if set to true, the showDelay and hideDelay settings are ignored, false by default
    • showDelay - (optional) the time period that should pass before showing a tooltip, in ms
    • hideDelay - (optional) the time period that should pass before hiding a tooltip, in ms
    • margin - (optional) the margin between the node and tooltip; 8px by default
    • position - (optional) the position of a tooltip: "right", "bottom", "center", "left", "top"; "bottom" by default
    • css - (optional) the style of a tooltip box
    The tooltip config can be redefined for the header/footer tooltip
    tooltipTemplate(optional) a function which returns a template for the content of the tooltip. Takes 3 parameters:
    • value - (required) the value of a cell
    • row - (required) an object with all cells in a row
    • column - (required) an object with the configuration of a column (see the columns config)
    Returning false from the function will block showing of the tooltip
    groupable(optional) PRO version only, enables data grouping by the values of a certain column. Columns' header can be dragged to the special grouping area - group panel. Grid will automatically create data groups based on the values of these columns. Note that the groupable property works only with the group panel
    closable(optional) PRO version only, either allows closing a particular element of the group panel or makes it permanently enabled
    summary(optional) creates the list of calculated values based on the column's data. The defined list is available only at the column's level. Can be initialized either as an object or as a string. As an object it contains calculated values set as key:value pairs, where the keys are the field names and values can be:
    • a string with the name of the applied functor
    • a tuple [string, string] that specifies the field name and the name of the applied functor
    • a (rows: IRow[]) => string | number; function for calculating the summary of the column
    Note that, when the column summary property is initialized as a string, the resulting value (excluding "count") is used with applied patternMask/numberMask, if there are any.

    Example

    Related articles: