Column

The base class for all other grid column types, used if no type is specified on a column.

Default editor is a TextField.

const grid = new Grid({
  columns : [{
    field : 'name',
    text  : 'Name'
  }, {
    text  : 'Hobby',
    field : 'others.hobby', // reading nested field data
  }, {
    type  : 'number', // Will use NumberColumn
    field : 'age',
    text  : 'Age'
  }]
});

Column types

Grid ships with multiple different column types. Which type to use for a column is specified by the type config. The built-in types are:

  • action - displays actions (clickable icons) in the cell.
  • aggregate - a column, which, when used as part of a Tree, aggregates the values of this column's descendants using a configured function which defaults to sum.
  • check - displays a checkbox in the cell.
  • date - displays a date in the specified format.
  • number - a column for showing/editing numbers.
  • percent - displays a basic progress bar.
  • rating - displays a star rating.
  • rownumber - displays the row number in each cell.
  • template - uses a template for cell content.
  • time - displays a time in the specified format.
  • tree - displays a tree structure when using the tree feature.
  • widget - displays widgets in the cells.

Tree columns

You can add tree rendering to any column type by configuring it with tree : true:

const grid = new TreeGrid({
   columns : [
       // These are equivalent:
       { type: 'tree', field: 'name' },
       { field: 'name', tree: true },

       // Any column type can be a tree column:
       { type: 'check', tree: true, field: 'done' }
   ]
});

Grouped columns / headers

You can group headers by defining parent and children columns. A group can be dragged as a whole, or users can drag individual columns between groups. The same applies to column visibility using the column picker in the header menu, a group can be toggled as a whole or each column individually.

const grid = new Grid({
    {
            text     : 'Parent',
            children : [
                { text : 'Child 1', field : 'field1', flex : 1 },
                { text : 'Child 2', field : 'field2', flex : 1 }
            ]
        },
        ...
}

Grouped columns
//<code-header>
fiddle.title = 'Grouped columns';
//</code-header>
const grid = new Grid({
    appendTo   : targetElement,
    autoHeight : true,
    data       : DataGenerator.generateData(3),
    columns    : [
        {
            text     : 'Employee',
            children : [
                { text : 'First name', field : 'firstName', flex : 1 },
                { text : 'Surname', field : 'surName', flex : 1 }
            ]
        },
        {
            text     : 'Other Info',
            children : [
                { text : 'City', field : 'city', width : 150 },
                { text : 'Notes', field : 'notes', flex : 2 }
            ]
        }
    ]
});

Collapsible columns

By configuring a parent column with collapsible: true it is made collapsible. When collapsing all child columns except the first one are hidden. This behaviour is configurable using the collapseMode config. To make a column start collapsed, set the collapsed config to true.

Column collapse
//<code-header>
fiddle.title = 'Column collapse';
//</code-header>
const grid = new Grid({
    appendTo   : targetElement,
    autoHeight : true,
    data       : DataGenerator.generateData(3),
    columns    : [
        {
            text         : 'Employee (toggleAll)',
            collapsible  : true,
            collapsed    : true,
            collapseMode : 'toggleAll',
            children     : [
                { text : 'First name', field : 'firstName', flex : 1 },
                { text : 'Surname', field : 'surName', flex : 1 },
                { text : 'Name', field : 'name', flex : 1, toggleAllHidden : true }
            ]
        },
        {
            text        : 'Other Info (showFirst)',
            collapsible : true,
            children    : [
                { text : 'City', field : 'city', width : 150 },
                { text : 'Notes', field : 'notes', flex : 2 }
            ]
        }
    ]
});

Adding widgets to the column header

You can add custom widgets to the column header element using the headerWidgets config.

Column header widgets
//<code-header>
fiddle.title = 'Column header widgets';
//</code-header>
const grid = new Grid({
    appendTo   : targetElement,
    autoHeight : true,
    data       : DataGenerator.generateData(3),
    features   : {
        sort : 'name'
    },
    columns : [
        {
            text          : 'Name',
            field         : 'name',
            flex          : 1,
            headerWidgets : [
                {
                    type      : 'button',
                    text      : 'Add row',
                    rendition : 'filled',
                    style     : {
                        'margin-inline-start' : 'auto'
                    },
                    onClick() {
                        this.owner.grid.store.add({ name : 'New user' });
                    }
                }
            ]
        },
        { text : 'City', field : 'city', width : 150 },
        { text : 'Notes', field : 'notes', flex : 2 }
    ]
});

Cell renderers and customizing cell content

Completely controlling cell contents

To completely control what is rendered into a cell, provide a renderer function which returns a string or a DomConfig DOM configuration object.

const grid = new Grid({
  columns : [
  ...
    {
      field      : 'approved',
      text       : 'Approved',
      htmlEncode : false, // allow to use HTML code
      renderer({ value }) {
        return value === true ? '<b>Yes</b>' : '<i>No</i>';
      }
    }
    ...
    ]
});

Augmenting the default rendering

To augment the default rendering of Column types which have their own special renderer, you can call the built-in renderer from your custom renderer, and use the result. For example, to highlight modified dates in a DateColumn:

new Grid({
    columns : [
        ...
        {
            type  : 'date',
            field : 'startDate',
            text  : 'Start Date',
            renderer({ record, value }) {
                const result = this.defaultRenderer({ value });

                return record.isFieldModified('startDate') ? `<span class="modified">${result}</span>` : result;
            }
        }
    ]
});

Mutating the cell element after the default rendering

You can also use the afterRenderCell callback to mutate the cell element after the default rendering.

new Grid({
    columns : [
        {
            text     : 'Name',
            afterRenderCell : ({ record, row, cellElement }) => {
                cellElement.classList.toggle('myClass', true);
                // Add special CSS class to new rows that have not yet been saved
                row.cls.newRow = record.isPhantom;
            }
        }
    ]
});

You can add custom items to the context menu for a columns header and for its cells, using headerMenuItems and cellMenuItems. Here is an example:

const grid = new Grid({
  columns : [
    ...
    {
      type  : 'number',
      field : 'age',
      text  : 'Age',
      headerMenuItems: [{
          text : 'My unique header item',
          icon : 'fa fa-paw',
          onItem() { console.log('item clicked'); }
      }],
      cellMenuItems: [{
          text : 'My unique cell item',
          icon : 'fa fa-plus',
          onItem() { console.log('item clicked'); }
      }]
    }
  ...
  ]
});

Columns without a width will shrink or expand to the pinnedWidth value when pinned.

Configs

80

Common

This config enables automatic height for all cells in this column. It is achieved by measuring the height a cell after rendering it to DOM, and then sizing the row using that height (if it is greater than other heights used for the row).

Heads up if you render your Grid on page load, if measurement happens before the font you are using is loaded you might get slightly incorrect heights. For browsers that support it we detect that and remeasure when fonts are available.

NOTE: Enabling this config comes with a pretty big performance hit. To maintain good performance, we recommend not using it. You can still set the height of individual rows manually, either through data or via renderers.

Also note that this setting only works fully as intended with non-flex columns.

Rows will always be at least rowHeight pixels tall even if an autoHeight cell contains no data.

Manually setting a height from a renderer in this column will take precedence over this config.

autoWidth: Boolean | Number | Number[]Also a property

This config sizes a column to fits its content. It is used instead of width or flex.

This config requires the ColumnAutoWidth feature which responds to changes in the grid's store and synchronizes the widths' of all autoWidth columns.

If this config is not a Boolean value, it is passed as the only argument to the resizeToFitContent method to constrain the column's width.

The name of the data model field to read a cells value from.

Also accepts dot notation to read nested or related data, for example 'address.city'.

fitMode: exact | textContent | value | none | null= 'exact'Also a property

Mode to use when measuring the contents of this column in calls to resizeToFitContent. Available modes are:

  • 'exact' - Most precise, renders and measures all cells (Default, slowest)
  • 'textContent' - Renders all cells but only measures the one with the longest textContent
  • 'value' - Renders and measures only the cell with the longest data (Fastest)
  • 'none'/falsy - Resize to fit content not allowed, a call does nothing
flex: Number | StringAlso a property

Column width as a flex weight. All columns with flex specified divide the available space (after subtracting fixed widths) between them according to the flex value. Columns that have flex : 2 will be twice as wide as those with flex : 1 (and so on)

maxWidth: Number | StringAlso a property

Column maximal width. If value is Number, then maximal width is in pixels

The text to show in the column header. You can display text vertically by setting the headerWritingMode property.

width: Number | StringAlso a property

Column width. If value is Number then width is in pixels

listenersEvents

Accessibility

The aria-label to use for this Column`s header element

The aria-label to use for cells in this Column

Export

Used by the Export feature. Set to false to omit a column from an exported dataset

Column type which will be used by TableExporter. See list of available types in TableExporter docs. Returns undefined by default, which means column type should be read from the record field.

Integration

Flag to enable vue component rendering

Interaction

A config object used to configure an Editor which contains this Column's input field if CellEdit feature is enabled.

collapsed: Boolean= falseAlso a property

The collapsed state of this column, only applicable for parent columns

collapseMode: String= 'showFirst'Also a property

The collapse behavior when collapsing a parent column. Specify "toggleAll" or "showFirst".

  • "showFirst" toggles visibility of all but the first columns.

  • "toggleAll" toggles all children, useful if you have a special initially hidden column which gets shown in collapsed state. To specify which columns are initially hidden, configure them with toggleAllHidden.

In the snippet below, the first two child columns are initially shown, while the third is initially hidden. When collapsing the parent column, the visibility of all three children will be toggled, so the third column will be shown and the first two hidden.

new Grid({
   columns : [{
         text        : 'Parent',
         collapsible : true,
         collapseMode : 'toggleAll',
         children    : [
             { text : 'Shown initially', field : 'field1', flex : 1 },
             { text : 'Shown initially', field : 'field2', flex : 1 },
             { text : 'Hidden initially', field : 'field3', flex : 1, toggleAllHidden : true }
         ]
   }]
});

{@note}Note that when using toggleAll mode, at least one child column must be configured with toggleAllHidden: true and at least one must not.{@/note}

If true, this column will show a collapse/expand icon in its header, only applicable for parent columns

Set to false to prevent this column header from being dragged

editor: Boolean | String | InputFieldConfig | Field | function | nullAlso a property

A config object used to create the input field which will be used for editing cells in the column. Used when CellEdit feature is enabled. The Editor refers to field for a data source.

Configure this as false or null to prevent cell editing in this column.

All subclasses of Field can be used as editors. The most popular are:

If record has method set + capitalized field, method will be called, e.g. if record has method named setFoobar and the field is foobar, then instead of record.foobar = value, record.setFoobar(value) will be called.

Function may be used for React application parameter for using JSX components as editors.

 columns : [
        {
            type   : 'name',
            field  : 'name',
            width  : 250,
            editor : ref => <TextEditor ref={ref}/>
        },
        ...
]

where passing ref to the React editor is essential for the editor to work.

NOTE: React editor component must implement setValue method which usually internally calls setState. React setState is asynchronous so we need to return Promise which will be resolved when setState finishes. A typical example of setValue method implemented in a React editor is:

setValue(value) {
    return new Promise(resolve => this.setState({ value }, () => resolve(value)));
}

Please consult the React Integration Guide for details on usage of React cell editors.

Note that for Column subclasses which have a default editor, the editor config is merged with the Column class's default editor config. This allows an application to reconfigure the default editor to conform to requirements for a specific column:

new Grid({
    columns : [{
        type  : 'date',
        field : 'date',
        // Override defaults for the date editor
        editor : {
            step : null // disable back/forward stepping
        }
    }]
});
ParameterTypeDescription
ref*

React RefObject for editor JSX component.

Returns: * -

Returns React editor JSX component template

filterable: Boolean | function | Object= trueAlso a property

Allow filtering data in the column (if Filter or FilterBar feature is enabled).

Also allows passing a custom filtering function that will be called for each record with a single argument of format { value, record, [operator] }. Returning true from the function includes the record in the filtered set.

Configuration object may be used for FilterBar feature to specify filterField. See an example in the code snippet below or check FilterBar page for more details.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             // Disable filtering for this column
             filterable : false
         },
         {
             field : 'age',
             // Custom filtering for this column
             filterable: ({ value, record }) => Math.abs(record.age - value) < 10
         },
         {
             field : 'start',
             // Changing default field type
             filterable: {
                 filterField : {
                     type : 'datetime'
                 }
             }
         },
         {
             field : 'city',
             // Filtering for a value out of a list of values
             filterable: {
                 filterField : {
                     type  : 'combo',
                     value : '',
                     items : [
                         'Paris',
                         'Dubai',
                         'Montreal',
                         'London',
                         'New York'
                     ]
                 }
             }
         },
         {
             field : 'score',
             filterable : {
                 // This filter fn doesn't return 0 values as matching filter 'less than'
                 filterFn : ({ record, value, operator, property }) => {
                     switch (operator) {
                         case '<':
                             return record[property] === 0 ? false : record[property] < value;
                         case '=':
                             return record[property] == value;
                         case '>':
                             return record[property] > value;
                     }
                 }
             }
         }
    ]
});

When providing a custom filtering function, if the filter feature is configured with prioritizeColumns : true that function will also be used for programmatic filtering of the store:

const grid = new Grid({
    features : {
        filter : {
            prioritizeColumns : true
        }
    },

    columns : [
         {
             field : 'age',
             // Custom filtering for this column
             filterable: ({ value, record }) => Math.abs(record.age - value) < 10
         }
    ]
});

// Will use filterable() from the column definition above
grid.store.filter({
    property : 'age',
    value    : 50
});

To use custom FilterField combo store it should contain one of these data or readUrl configs. Otherwise combo will get data from owner Grid store.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             filterable: {
                 filterField {
                     type  : 'combo',
                     store : new Store({
                         data : ['Adam', 'Bob', 'Charlie']
                     })
                 }
             }
         }
    ]
});

or

const grid = new Grid({
    columns : [
         {
             field : 'name',
             filterable: {
                 filterField : {
                    type  : 'combo',
                    store : new AjaxStore({
                        readUrl  : 'data/names.json',
                        autoLoad : true
                    })
                 }
             }
         }
    ]
});
ParameterTypeDescription
dataObject

Data object

data.value*

Record value

data.recordModel

Record instance

Returns: Boolean -

Returns true if value matches condition

A function which is called when a cell edit is requested to finish.

This may be an async function which performs complex validation. The return value should be:

  • false - To indicate a generic validation error
  • true - To indicate a successful validation, which will complete the editing
  • a string - To indicate an error message of the failed validation. This error message will be cleared upon any subsequent user input.

The action for the failed validation is defined with the invalidAction config.

For example for synchronous validation:

const grid = new Grid({
   columns : [
      {
         type : 'text',
         text : 'The column',
         field : 'someField',
         flex : 1,
         finalizeCellEdit : ({ value }) => {
             return value.length < 4 ? 'Value length should be at least 4 characters' : true;
         }
      }
   ]
});

Here we've defined a validation finalizeCellEdit function, which marks all edits with new value less than 4 characters length as invalid.

For asynchronous validation you can make the validation function async:

finalizeCellEdit : async ({ value }) => {
    return await performRemoteValidation(value);
}
ParameterTypeDescription
contextObject

An object describing the state of the edit at completion request time.

context.inputFieldField

The field configured as the column's editor.

context.recordModel

The record being edited.

context.oldValue*

The old value of the cell.

context.value*

The new value of the cell.

context.gridGrid

The host grid.

context.editorContextObject

The CellEdit context object.

context.editorContext.columnColumn

The column being edited.

context.editorContext.recordModel

The record being edited.

context.editorContext.cellHTMLElement

The cell element hosting the editor.

context.editorContext.editorEditor

The floating Editor widget which is hosting the input field.

Returns: Boolean | void

Set to false to prevent grouping by this column

Allow column visibility to be toggled through UI

invalidAction: block | allow | revert= 'block'Also a property

How to handle a request to complete a cell edit in this column if the field is invalid. There are three choices:

  • block The default. The edit is not exited, the field remains focused.
  • allow Allow the edit to be completed.
  • revert The field value is reverted and the edit is completed.

By default, cell editing is finalized when the editor is blurred or if the user taps outside the editor. For complex custom editors, focus or tapping might be expected outside the Bryntum owned editor. In such cases, supply false for this config to take manual control over when cell editing in the column should be finalized.

To accept changes, call finishEditing. To reject, call cancelEditing.

// Setup
const grid = new Grid({
  columns : [
    {
      text               : 'Skills',
      field              : 'skills',
      managedCellEditing : false
    }
  ]
});

// From your custom editor, when you are ready to accept changes
grid.finishEditing();

Set to false to prevent the column from being drag-resized when the ColumnResize plugin is enabled.

Setting this option means that pressing the ESCAPE key after editing the field will revert the field to the value it had when the edit began. If the value is not changed from when the edit started, the input field's clearable behaviour will be activated. Finally, the edit will be canceled.

sealed: Boolean= falseAlso a property

Setting this flag to true will prevent dropping child columns into a group column

Allow searching in the column (respected by QuickFind and Search features)

Allow sorting of data in the column. You can pass true/false to enable/disable sorting, or provide a custom sorting function, or a config object for a CollectionSorter

const grid = new Grid({
    columns : [
         {
             // Disable sorting for this column
             sortable : false
         },
         {
             field : 'name',
             // Custom sorting for this column
             sortable(user1, user2) {
                 return user1.name < user2.name ? -1 : 1;
             }
         },
         {
             // A config object for a Core.util.CollectionSorter
             sortable : {
                 property         : 'someField',
                 direction        : 'DESC',
                 useLocaleCompare : 'sv-SE'
             }
         }
    ]
});

When providing a custom sorting function, if the sort feature is configured with prioritizeColumns : true that function will also be used for programmatic sorting of the store:

const grid = new Grid({
    features : {
      sort : {
          prioritizeColumns : true
      }
    },

    columns : [
         {
             field : 'name',
             // Custom sorting for this column
             sortable(user1, user2) {
                 return user1.name < user2.name ? -1 : 1;
             }
         }
    ]
});

// Will use sortable() from the column definition above
grid.store.sort('name');

Also, any custom sorter function is called with an additional parameter indicating the sort direction. Please note that is an informative parameter, the result of the sort function is already reversed if needed depending on direction.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             // direction will be ASC or DESC
             sortable(user1, user2, direction) {
                 return user1.name < user2.name ? -1 : 1;
             }
         }
    ]
});
ParameterTypeDescription
leftModel

Left side model to compare

rightModel

Right side model to compare

Returns: Number

Only applies for leaf columns in a collapsible group configured with collapseMode : 'toggleAll'. Specify true to show the column when the group is collapsed, false to hide it.

See collapseMode for more details and an example.

Layout

align: left | center | right | start | endAlso a property

Text align. Accepts 'left'/'center'/'right' or direction neutral 'start'/'end'

Columns hidden state. Specify true to hide the column, false to show it.

locked: Boolean= falseAlso a property

Convenient way of putting a column in the "locked" region. Same effect as specifying region: 'locked'. If you have defined your own regions (using subGridConfigs) you should use region instead of this one.

minWidth: Number | String= 60Also a property

Column minimum width. If value is Number, then minimal width is in pixels

Region (part of the grid, it can be configured with multiple) where to display the column. Defaults to defaultRegion.

A column under a grouped header automatically belongs to the same region as the grouped header.

Menu

Extra items to show in the cell context menu for this column, null or false to not show any menu items for this column.

cellMenuItems : {
    customItem : { text : 'Custom item' }
}

Set to false to prevent showing a context menu on the cell elements in this column

false to prevent showing a context menu on the column header element

Extra items to show in the header context menu for this column.

// A rank column, which displays its header text vertically and offers a menu item to toggle that
{
    text              : 'Rank',
    field             : 'rank',
    width             : 30,
    type              : 'number',
    headerWritingMode : 'sideways-lr',
    align             : 'center',
    headerMenuItems   : {
        toggleVerticalText : {
            text    : 'Vertical header text',
            checked : true,
            weight  : 10,
            onItem  : ({ column }) => {
                column.headerWritingMode = column.headerWritingMode ? null : 'sideways-lr';
            }
        }
    }
},

Show column picker for the column

Merge cells

Set to false to prevent merging cells in this column using the column header menu.

Only applies when using the MergeCells feature.

Specify true to merge cells within the column whose value match between rows, making the first occurrence of the value span multiple rows.

Only applies when using the MergeCells feature.

This setting can also be toggled using the column header menu.

An empty function by default, but provided so that you can override it. This function is called each time a merged cell is rendered. It allows you to manipulate the DOM config object used before it is synced to DOM, thus giving you control over styling and contents.

NOTE: The function is intended for formatting, you should not update records in it since updating records triggers another round of rendering.

const grid = new Grid({
  columns : [
    {
      field      : 'project',
      text       : 'Project',
      mergeCells : 'true,
      mergedRenderer({ domConfig, value, fromIndex, toIndex }) {
        domConfig.className.highlight = value === 'Important project';
      }
   }
 ]
});
ParameterTypeDescription
detailObject

An object containing the information needed to render a task.

detail.value*

Value that will be displayed in the merged cell

detail.fromIndexNumber

Index in store of the first row of the merged cell

detail.toIndexNumber

Index in store of the last row of the merged cell

detail.domConfigDomConfig

DOM config object for the merged cell element

Returns: void

Misc

Set to false to not always clear cell content if the renderer returns undefined or has no return statement. This is useful when you mutate the cellElement, and want to prevent cell content from being reset during rendering.

Set to true to always clear cell content regardless of renderer return value.

Set to trueto automatically call DomHelper.sync for html returned from a renderer. Should in most cases be more performant than replacing entire innerHTML of cell and also allows CSS transitions to work. Has no effect unless htmlEncode is disabled. Returned html must contain a single root element (that can have multiple children). See PercentColumn for example usage.

An optional query selector to select a sub element within the cell being edited to align a cell editor's X position and width to.

filterType: text | date | number | durationAlso a property

Determines which type of filtering to use for the column. Usually determined by the column type used, but may be overridden by setting this field.

An array of the widgets to append to the column header. These widgets have this Column instance as their owner which can be used to reference the column, and the owning Grid via this.owner.grid.

columns : [
{
    text          : 'Name',
    field         : 'name',
    flex          : 1,
    headerWidgets : [
        {
            type      : 'button',
            text      : 'Add row',
            rendition : 'filled',
            async onAction() {
                const
                     grid = this.owner.grid,
                     [newRecord] = grid.store.add({
                         name : 'New user'
                     });

                await grid.scrollRowIntoView(newRecord);

                await grid.features.cellEdit.startEditing({
                    record : newRecord,
                    field  : 'name'
                });
            }
        }
    ]
}]
headerWritingMode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lrAlso a property

Applies a CSS class that controls the CSS writing-mode property for the column header text element.

{
    text              : 'Rank',
    field             : 'rank',
    width             : 30,
    type              : 'number',
    headerWritingMode : 'sideways-lr'
}

By default, any rendered column cell content is HTML-encoded. Set this flag to false disable this and allow rendering html elements

By default, the header text is HTML-encoded. Set this flag to false disable this and allow html elements in the column header

Set to true to have the CellEdit feature update the record being edited live upon field edit instead of when editing is finished by using TAB or ENTER

Column settings at different responsive levels, see responsive demo under examples/

Tags, may be used by ColumnPicker feature for grouping columns by tag in the menu

Column config to apply to normal config if viewed on a touch device

When using the tree feature, exactly one column should specify { tree: true }

localeClassLocalizable
localizableLocalizable

Other

Set to true to have the cell editor for this column inherit formula providers from the Grid's configured formulaProviders.

pinned: start | end | null | falseAlso a property

Set to 'end' or 'start' to pin the column to the respective side of the grid when PinColumns feature is enabled.

When a column is pinned and it does not have a width specified, pinnedWidth will be used instead.

Set this to true to not allow any type of editing in this column.

Rendering

A callback function called after every cell has been rendered, which lets you mutate the cell/row or contents. This is useful when you want to mutate contents of a pre-configured column (e.g. CheckColumn, WidgetColumn etc.) without overwriting the built-in renderer.

In the method, you can modify the cell / row elements, e.g. to add custom CSS classes:

new Grid({
    columns : [
        {
            text     : 'Name',
            afterRenderCell : ({ record, row, cellElement }) => {
                cellElement.classList.toggle('myClass', true);
                // Add special CSS class to new rows that have not yet been saved
                row.cls.newRow = record.isPhantom;
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject

Object containing rendering parameters

renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc. Can be null in case of export

renderData.value*

Value to be displayed in the cell

renderData.recordModel

Record for the row

renderData.columnColumn

This column

renderData.gridGrid

This grid

renderData.rowRow

Row object. Can be null in case of export. Use the row's API to manipulate CSS class names.

renderData.sizeObject

Set size.height to specify the desired row height for the current row. Largest specified height is used, falling back to configured rowHeight in case none is specified. Can be null in case of export

renderData.size.heightNumber

Set this to request a certain row height

renderData.size.configuredHeightNumber

Row height that will be used if none is requested

renderData.isExportBoolean

true if the record is being exported to Excel or a textual format, enabling special handling during export.

renderData.isMeasuringBoolean

True if the column is being measured for a resizeToFitContent call.

Returns: void | String | null -

Return value is only used by the export feature, not by row rendering

CSS class added to each cell in this column

CSS class added to the header of this column

Renderer function for group headers (when using Group feature).

You should never modify any records inside this method.
const grid = new Grid({
    columns : [
        {
            text : 'ABC',
            groupRenderer(renderData) {
                return {
                     class : {
                         big   : true,
                         small : false
                     },
                     children : [
                         { tag : 'img', src : 'img.png' },
                         renderData.groupRowFor
                     ]
                };
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject
renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc.

renderData.groupRowFor*

Current group value

renderData.recordModel

Record for the row

renderData.groupRecordsModel[]

Records in the group

renderData.columnColumn

Current rendering column

renderData.groupColumnColumn

Column that the grid is grouped by

renderData.countNumber

Number of records in the group

renderData.gridGrid

This grid

Returns: DomConfig | String | null -

The header grouping text or DomConfig object representing the HTML markup

Renderer function for the column header.

ParameterTypeDescription
renderDataObject
renderData.columnColumn

This column

renderData.headerElementHTMLElement

The header element

Returns: String | null -

The text or markup to show in the column header

Icon to display in header. Specifying an icon will render a <i> element with the icon as value for the class attribute

Renderer function, used to format and style the content displayed in the cell. Return the cell text you want to display. Can also affect other aspects of the cell, such as styling.

You should never modify any records inside this method.

If you provide a renderer to a built-in Column such as DateColumn, it will completely replace the native rendering. In these cases, you may want to call that column class's built-in renderer from your custom renderer to access the default rendered value.

If you mutate cellElement, and you want to prevent cell content from being reset during rendering, please return undefined from the renderer (or just omit the return statement) and make sure that the alwaysClearCell config is set to false.

new Grid({
    columns : [
        { text : 'Status', renderer : ({ record }) => record.status }
    ]
});

You can also return a DomConfig object describing the markup:

new Grid({
    columns : [
        {
             text : 'Status',
             renderer : ({ record }) => {
                 return {
                     class : 'myClass',
                     children : [
                         {
                             tag : 'i',
                             class : 'fa fa-pen'
                         },
                         {
                             tag : 'span',
                             text : record.name
                         }
                     ]
                 };
             }
        }
    ]
});

You can modify the row element too from inside a renderer to add custom CSS classes:

new Grid({
    columns : [
        {
            text     : 'Name',
            renderer : ({ record, row }) => {
               // Add special CSS class to new rows that have not yet been saved
              row.cls.newRow = record.isPhantom;

              return record.name;
        }
    ]
});

If you are adding a renderer to a column that has a built in renderer (like DateColumn or NumberColumn), you may call the built-in renderer from your custom renderer if you want to use the default content and modify it. For example, to highlight modified dates in a DateColumn:

new Grid({
    columns : [
        {
            type     : 'date',
            field    : 'startDate',
            text     : 'Start Date',
            renderer : ({ record, column }) => {
                let result = this.defaultRenderer(...arguments);

                // Highlight modified start dates
                if (record.isFieldModified('startDate')) {
                    result = `<span class="modified">${result}</span>`;
                }
                return result;
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject

Object containing renderer parameters

renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc. Can be null in case of export

renderData.value*

Value to be displayed in the cell

renderData.recordModel

Record for the row

renderData.columnColumn

This column

renderData.gridGrid

This grid

renderData.rowRow

Row object. Can be null in case of export. Use the row's API to manipulate CSS class names.

renderData.sizeObject

Set size.height to specify the desired row height for the current row. Largest specified height is used, falling back to configured rowHeight in case none is specified. Can be null in case of export

renderData.size.heightNumber

Set this to request a certain row height

renderData.size.configuredHeightNumber

Row height that will be used if none is requested

renderData.isExportBoolean

true if the record is being exported to Excel or a textual format, enabling special handling during export.

renderData.isMeasuringBoolean

True if the column is being measured for a resizeToFitContent call. In which case an advanced renderer might need to take different actions.

Returns: String | DomConfig | DomConfig[] | HTMLElement | null

A tooltip string to show when hovering the column header, or a config object which can reconfigure the shared tooltip by setting boolean, numeric and string config values.

tooltipRenderer: function | BooleanAlso a property

Renderer function for the cell tooltip (used with CellTooltip feature). Specify false to disable tooltip for this column.

You should never modify any records inside this method.
ParameterTypeDescription
renderDataObject
renderData.cellElementHTMLElement

Cell element

renderData.recordModel

Record for cell row

renderData.columnColumn

Cell column

renderData.cellTooltipCellTooltip

Feature instance, used to set tooltip content async

renderData.eventMouseEvent

The event that triggered the tooltip

Returns: String | DomConfig | null

Summary

sum: sum | add | count | countNotEmpty | average | functionAlso a property

Summary type (when using Summary feature). Valid types are:

  • 'sum' - Sum of all values in the column
  • 'add' - Alias for sum
  • 'count' - Number of rows
  • 'countNotEmpty' - Number of rows containing a value
  • 'average' - Average of all values in the column
  • callbackFn - A custom function, used with store.reduce. Its return value becomes the value of the accumulator parameter on the next invocation of callbackFn
ParameterTypeDescription
resultNumber | *

The value resulting from the previous call to callbackFn. On the first call, its value is initialValue if the latter is specified; otherwise its value is first element.

valueModel

The value of the current element.

indexNumber

The index position of currentValue. On the first call, its value is 0 if initialValue is specified, otherwise 1.

Returns: Number | *

Summary configs, use if you need multiple summaries per column. Replaces sum and summaryRenderer configs.

Renderer function for summary (when using Summary feature). The renderer is called with an object having the calculated summary sum parameter. Function returns a string value to be rendered.

Example:

columns : [{
    type            : 'number',
    text            : 'Score',
    field           : 'score',
    sum             : 'sum',
    summaryRenderer : ({ sum }) => `Total amount: ${sum}`
}]
ParameterTypeDescription
dataObject

Object containing renderer parameters

data.sumNumber | *

The sum parameter

Returns: String | DomConfig | null

Properties

151

Common

This config enables automatic height for all cells in this column. It is achieved by measuring the height a cell after rendering it to DOM, and then sizing the row using that height (if it is greater than other heights used for the row).

Heads up if you render your Grid on page load, if measurement happens before the font you are using is loaded you might get slightly incorrect heights. For browsers that support it we detect that and remeasure when fonts are available.

NOTE: Enabling this config comes with a pretty big performance hit. To maintain good performance, we recommend not using it. You can still set the height of individual rows manually, either through data or via renderers.

Also note that this setting only works fully as intended with non-flex columns.

Rows will always be at least rowHeight pixels tall even if an autoHeight cell contains no data.

Manually setting a height from a renderer in this column will take precedence over this config.

autoWidth: Boolean | Number | Number[]Also a config

This config sizes a column to fits its content. It is used instead of width or flex.

This config requires the ColumnAutoWidth feature which responds to changes in the grid's store and synchronizes the widths' of all autoWidth columns.

If this config is not a Boolean value, it is passed as the only argument to the resizeToFitContent method to constrain the column's width.

field: StringreadonlyAlso a config

The name of the data model field to read a cells value from.

Also accepts dot notation to read nested or related data, for example 'address.city'.

fitMode: exact | textContent | value | none | null= 'exact'Also a config

Mode to use when measuring the contents of this column in calls to resizeToFitContent. Available modes are:

  • 'exact' - Most precise, renders and measures all cells (Default, slowest)
  • 'textContent' - Renders all cells but only measures the one with the longest textContent
  • 'value' - Renders and measures only the cell with the longest data (Fastest)
  • 'none'/falsy - Resize to fit content not allowed, a call does nothing
flex: Number | StringAlso a config

Column width as a flex weight. All columns with flex specified divide the available space (after subtracting fixed widths) between them according to the flex value. Columns that have flex : 2 will be twice as wide as those with flex : 1 (and so on)

maxWidth: Number | StringAlso a config

Column maximal width. If value is Number, then maximal width is in pixels

The text to show in the column header. You can display text vertically by setting the headerWritingMode property.

width: Number | StringAlso a config

Column width. If value is Number then width is in pixels

Accessibility

The aria-label to use for this Column`s header element

The aria-label to use for cells in this Column

Class hierarchy

isColumn: Boolean= truereadonly
Identifies an object as an instance of Column class, or subclass thereof.
isColumn: Boolean= truereadonlystatic
Identifies an object as an instance of Column class, or subclass thereof.
isEventsEvents
isLocalizableLocalizable
isModelModel
isModelLinkModelLink
isModelStmModelStm
isTreeNodeTreeNode

Export

Used by the Export feature. Set to false to omit a column from an exported dataset

Column type which will be used by TableExporter. See list of available types in TableExporter docs. Returns undefined by default, which means column type should be read from the record field.

Integration

Flag to enable vue component rendering

Interaction

A config object used to configure an Editor which contains this Column's input field if CellEdit feature is enabled.

collapsed: Boolean= falseAlso a config

The collapsed state of this column, only applicable for parent columns

collapseMode: String= 'showFirst'Also a config

The collapse behavior when collapsing a parent column. Specify "toggleAll" or "showFirst".

  • "showFirst" toggles visibility of all but the first columns.

  • "toggleAll" toggles all children, useful if you have a special initially hidden column which gets shown in collapsed state. To specify which columns are initially hidden, configure them with toggleAllHidden.

In the snippet below, the first two child columns are initially shown, while the third is initially hidden. When collapsing the parent column, the visibility of all three children will be toggled, so the third column will be shown and the first two hidden.

new Grid({
   columns : [{
         text        : 'Parent',
         collapsible : true,
         collapseMode : 'toggleAll',
         children    : [
             { text : 'Shown initially', field : 'field1', flex : 1 },
             { text : 'Shown initially', field : 'field2', flex : 1 },
             { text : 'Hidden initially', field : 'field3', flex : 1, toggleAllHidden : true }
         ]
   }]
});

{@note}Note that when using toggleAll mode, at least one child column must be configured with toggleAllHidden: true and at least one must not.{@/note}

collapsible: Boolean= falseAlso a config

If true, this column will show a collapse/expand icon in its header, only applicable for parent columns

Set to false to prevent this column header from being dragged

editor: Boolean | String | InputFieldConfig | Field | function | nullAlso a config

A config object used to create the input field which will be used for editing cells in the column. Used when CellEdit feature is enabled. The Editor refers to field for a data source.

Configure this as false or null to prevent cell editing in this column.

All subclasses of Field can be used as editors. The most popular are:

If record has method set + capitalized field, method will be called, e.g. if record has method named setFoobar and the field is foobar, then instead of record.foobar = value, record.setFoobar(value) will be called.

Function may be used for React application parameter for using JSX components as editors.

 columns : [
        {
            type   : 'name',
            field  : 'name',
            width  : 250,
            editor : ref => <TextEditor ref={ref}/>
        },
        ...
]

where passing ref to the React editor is essential for the editor to work.

NOTE: React editor component must implement setValue method which usually internally calls setState. React setState is asynchronous so we need to return Promise which will be resolved when setState finishes. A typical example of setValue method implemented in a React editor is:

setValue(value) {
    return new Promise(resolve => this.setState({ value }, () => resolve(value)));
}

Please consult the React Integration Guide for details on usage of React cell editors.

Note that for Column subclasses which have a default editor, the editor config is merged with the Column class's default editor config. This allows an application to reconfigure the default editor to conform to requirements for a specific column:

new Grid({
    columns : [{
        type  : 'date',
        field : 'date',
        // Override defaults for the date editor
        editor : {
            step : null // disable back/forward stepping
        }
    }]
});
ParameterTypeDescription
ref*

React RefObject for editor JSX component.

Returns: * -

Returns React editor JSX component template

filterable: Boolean | function | Object= trueAlso a config

Allow filtering data in the column (if Filter or FilterBar feature is enabled).

Also allows passing a custom filtering function that will be called for each record with a single argument of format { value, record, [operator] }. Returning true from the function includes the record in the filtered set.

Configuration object may be used for FilterBar feature to specify filterField. See an example in the code snippet below or check FilterBar page for more details.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             // Disable filtering for this column
             filterable : false
         },
         {
             field : 'age',
             // Custom filtering for this column
             filterable: ({ value, record }) => Math.abs(record.age - value) < 10
         },
         {
             field : 'start',
             // Changing default field type
             filterable: {
                 filterField : {
                     type : 'datetime'
                 }
             }
         },
         {
             field : 'city',
             // Filtering for a value out of a list of values
             filterable: {
                 filterField : {
                     type  : 'combo',
                     value : '',
                     items : [
                         'Paris',
                         'Dubai',
                         'Montreal',
                         'London',
                         'New York'
                     ]
                 }
             }
         },
         {
             field : 'score',
             filterable : {
                 // This filter fn doesn't return 0 values as matching filter 'less than'
                 filterFn : ({ record, value, operator, property }) => {
                     switch (operator) {
                         case '<':
                             return record[property] === 0 ? false : record[property] < value;
                         case '=':
                             return record[property] == value;
                         case '>':
                             return record[property] > value;
                     }
                 }
             }
         }
    ]
});

When providing a custom filtering function, if the filter feature is configured with prioritizeColumns : true that function will also be used for programmatic filtering of the store:

const grid = new Grid({
    features : {
        filter : {
            prioritizeColumns : true
        }
    },

    columns : [
         {
             field : 'age',
             // Custom filtering for this column
             filterable: ({ value, record }) => Math.abs(record.age - value) < 10
         }
    ]
});

// Will use filterable() from the column definition above
grid.store.filter({
    property : 'age',
    value    : 50
});

To use custom FilterField combo store it should contain one of these data or readUrl configs. Otherwise combo will get data from owner Grid store.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             filterable: {
                 filterField {
                     type  : 'combo',
                     store : new Store({
                         data : ['Adam', 'Bob', 'Charlie']
                     })
                 }
             }
         }
    ]
});

or

const grid = new Grid({
    columns : [
         {
             field : 'name',
             filterable: {
                 filterField : {
                    type  : 'combo',
                    store : new AjaxStore({
                        readUrl  : 'data/names.json',
                        autoLoad : true
                    })
                 }
             }
         }
    ]
});
ParameterTypeDescription
dataObject

Data object

data.value*

Record value

data.recordModel

Record instance

Returns: Boolean -

Returns true if value matches condition

A function which is called when a cell edit is requested to finish.

This may be an async function which performs complex validation. The return value should be:

  • false - To indicate a generic validation error
  • true - To indicate a successful validation, which will complete the editing
  • a string - To indicate an error message of the failed validation. This error message will be cleared upon any subsequent user input.

The action for the failed validation is defined with the invalidAction config.

For example for synchronous validation:

const grid = new Grid({
   columns : [
      {
         type : 'text',
         text : 'The column',
         field : 'someField',
         flex : 1,
         finalizeCellEdit : ({ value }) => {
             return value.length < 4 ? 'Value length should be at least 4 characters' : true;
         }
      }
   ]
});

Here we've defined a validation finalizeCellEdit function, which marks all edits with new value less than 4 characters length as invalid.

For asynchronous validation you can make the validation function async:

finalizeCellEdit : async ({ value }) => {
    return await performRemoteValidation(value);
}
ParameterTypeDescription
contextObject

An object describing the state of the edit at completion request time.

context.inputFieldField

The field configured as the column's editor.

context.recordModel

The record being edited.

context.oldValue*

The old value of the cell.

context.value*

The new value of the cell.

context.gridGrid

The host grid.

context.editorContextObject

The CellEdit context object.

context.editorContext.columnColumn

The column being edited.

context.editorContext.recordModel

The record being edited.

context.editorContext.cellHTMLElement

The cell element hosting the editor.

context.editorContext.editorEditor

The floating Editor widget which is hosting the input field.

Returns: Boolean | void

Set to false to prevent grouping by this column

hideable: Boolean= trueAlso a config

Allow column visibility to be toggled through UI

invalidAction: block | allow | revert= 'block'Also a config

How to handle a request to complete a cell edit in this column if the field is invalid. There are three choices:

  • block The default. The edit is not exited, the field remains focused.
  • allow Allow the edit to be completed.
  • revert The field value is reverted and the edit is completed.

By default, cell editing is finalized when the editor is blurred or if the user taps outside the editor. For complex custom editors, focus or tapping might be expected outside the Bryntum owned editor. In such cases, supply false for this config to take manual control over when cell editing in the column should be finalized.

To accept changes, call finishEditing. To reject, call cancelEditing.

// Setup
const grid = new Grid({
  columns : [
    {
      text               : 'Skills',
      field              : 'skills',
      managedCellEditing : false
    }
  ]
});

// From your custom editor, when you are ready to accept changes
grid.finishEditing();
resizable: Boolean= trueAlso a config

Set to false to prevent the column from being drag-resized when the ColumnResize plugin is enabled.

Setting this option means that pressing the ESCAPE key after editing the field will revert the field to the value it had when the edit began. If the value is not changed from when the edit started, the input field's clearable behaviour will be activated. Finally, the edit will be canceled.

sealed: Boolean= falseAlso a config

Setting this flag to true will prevent dropping child columns into a group column

Allow searching in the column (respected by QuickFind and Search features)

sortable: Boolean | function | CollectionSorterConfig= trueAlso a config

Allow sorting of data in the column. You can pass true/false to enable/disable sorting, or provide a custom sorting function, or a config object for a CollectionSorter

const grid = new Grid({
    columns : [
         {
             // Disable sorting for this column
             sortable : false
         },
         {
             field : 'name',
             // Custom sorting for this column
             sortable(user1, user2) {
                 return user1.name < user2.name ? -1 : 1;
             }
         },
         {
             // A config object for a Core.util.CollectionSorter
             sortable : {
                 property         : 'someField',
                 direction        : 'DESC',
                 useLocaleCompare : 'sv-SE'
             }
         }
    ]
});

When providing a custom sorting function, if the sort feature is configured with prioritizeColumns : true that function will also be used for programmatic sorting of the store:

const grid = new Grid({
    features : {
      sort : {
          prioritizeColumns : true
      }
    },

    columns : [
         {
             field : 'name',
             // Custom sorting for this column
             sortable(user1, user2) {
                 return user1.name < user2.name ? -1 : 1;
             }
         }
    ]
});

// Will use sortable() from the column definition above
grid.store.sort('name');

Also, any custom sorter function is called with an additional parameter indicating the sort direction. Please note that is an informative parameter, the result of the sort function is already reversed if needed depending on direction.

const grid = new Grid({
    columns : [
         {
             field : 'name',
             // direction will be ASC or DESC
             sortable(user1, user2, direction) {
                 return user1.name < user2.name ? -1 : 1;
             }
         }
    ]
});
ParameterTypeDescription
leftModel

Left side model to compare

rightModel

Right side model to compare

Returns: Number

Only applies for leaf columns in a collapsible group configured with collapseMode : 'toggleAll'. Specify true to show the column when the group is collapsed, false to hide it.

See collapseMode for more details and an example.

Layout

align: left | center | right | start | endAlso a config

Text align. Accepts 'left'/'center'/'right' or direction neutral 'start'/'end'

Columns hidden state. Specify true to hide the column, false to show it.

locked: Boolean= falseAlso a config

Convenient way of putting a column in the "locked" region. Same effect as specifying region: 'locked'. If you have defined your own regions (using subGridConfigs) you should use region instead of this one.

minWidth: Number | String= 60Also a config

Column minimum width. If value is Number, then minimal width is in pixels

Region (part of the grid, it can be configured with multiple) where to display the column. Defaults to defaultRegion.

A column under a grouped header automatically belongs to the same region as the grouped header.

Menu

Extra items to show in the cell context menu for this column, null or false to not show any menu items for this column.

cellMenuItems : {
    customItem : { text : 'Custom item' }
}

Set to false to prevent showing a context menu on the cell elements in this column

false to prevent showing a context menu on the column header element

Extra items to show in the header context menu for this column.

// A rank column, which displays its header text vertically and offers a menu item to toggle that
{
    text              : 'Rank',
    field             : 'rank',
    width             : 30,
    type              : 'number',
    headerWritingMode : 'sideways-lr',
    align             : 'center',
    headerMenuItems   : {
        toggleVerticalText : {
            text    : 'Vertical header text',
            checked : true,
            weight  : 10,
            onItem  : ({ column }) => {
                column.headerWritingMode = column.headerWritingMode ? null : 'sideways-lr';
            }
        }
    }
},

Show column picker for the column

Merge cells

mergeable: Boolean= trueAlso a config

Set to false to prevent merging cells in this column using the column header menu.

Only applies when using the MergeCells feature.

Specify true to merge cells within the column whose value match between rows, making the first occurrence of the value span multiple rows.

Only applies when using the MergeCells feature.

This setting can also be toggled using the column header menu.

An empty function by default, but provided so that you can override it. This function is called each time a merged cell is rendered. It allows you to manipulate the DOM config object used before it is synced to DOM, thus giving you control over styling and contents.

NOTE: The function is intended for formatting, you should not update records in it since updating records triggers another round of rendering.

const grid = new Grid({
  columns : [
    {
      field      : 'project',
      text       : 'Project',
      mergeCells : 'true,
      mergedRenderer({ domConfig, value, fromIndex, toIndex }) {
        domConfig.className.highlight = value === 'Important project';
      }
   }
 ]
});
ParameterTypeDescription
detailObject

An object containing the information needed to render a task.

detail.value*

Value that will be displayed in the merged cell

detail.fromIndexNumber

Index in store of the first row of the merged cell

detail.toIndexNumber

Index in store of the last row of the merged cell

detail.domConfigDomConfig

DOM config object for the merged cell element

Returns: void

Misc

Set to false to not always clear cell content if the renderer returns undefined or has no return statement. This is useful when you mutate the cellElement, and want to prevent cell content from being reset during rendering.

Set to true to always clear cell content regardless of renderer return value.

Set to trueto automatically call DomHelper.sync for html returned from a renderer. Should in most cases be more performant than replacing entire innerHTML of cell and also allows CSS transitions to work. Has no effect unless htmlEncode is disabled. Returned html must contain a single root element (that can have multiple children). See PercentColumn for example usage.

An optional query selector to select a sub element within the cell being edited to align a cell editor's X position and width to.

filterType: text | date | number | durationAlso a config

Determines which type of filtering to use for the column. Usually determined by the column type used, but may be overridden by setting this field.

An array of the widgets to append to the column header. These widgets have this Column instance as their owner which can be used to reference the column, and the owning Grid via this.owner.grid.

columns : [
{
    text          : 'Name',
    field         : 'name',
    flex          : 1,
    headerWidgets : [
        {
            type      : 'button',
            text      : 'Add row',
            rendition : 'filled',
            async onAction() {
                const
                     grid = this.owner.grid,
                     [newRecord] = grid.store.add({
                         name : 'New user'
                     });

                await grid.scrollRowIntoView(newRecord);

                await grid.features.cellEdit.startEditing({
                    record : newRecord,
                    field  : 'name'
                });
            }
        }
    ]
}]
headerWritingMode: horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lrAlso a config

Applies a CSS class that controls the CSS writing-mode property for the column header text element.

{
    text              : 'Rank',
    field             : 'rank',
    width             : 30,
    type              : 'number',
    headerWritingMode : 'sideways-lr'
}

By default, any rendered column cell content is HTML-encoded. Set this flag to false disable this and allow rendering html elements

By default, the header text is HTML-encoded. Set this flag to false disable this and allow html elements in the column header

Set to true to have the CellEdit feature update the record being edited live upon field edit instead of when editing is finished by using TAB or ENTER

Column settings at different responsive levels, see responsive demo under examples/

Tags, may be used by ColumnPicker feature for grouping columns by tag in the menu

Column config to apply to normal config if viewed on a touch device

tree: BooleanreadonlyAlso a config

When using the tree feature, exactly one column should specify { tree: true }

localeHelperLocalizable
localeManagerLocalizable
stmModelStm

Other

contentElement: HTMLElementreadonly

The child element into which content should be placed. This means where any contained widgets such as filter input fields should be rendered. Only available after the grid has been rendered.

Note that column headers are rerendered upon mutation of Column values, so this value is volatile and should not be cached, but should be read whenever needed.

defaults: Objectreadonly

Default settings for the column, applied in constructor. None by default, override in subclass.

Returns: Object
element: HTMLElementreadonly

The header element for this Column. Only available after the grid has been rendered.

Note that column headers are rerendered upon mutation of Column values, so this value is volatile and should not be cached, but should be read whenever needed.

Set to true to have the cell editor for this column inherit formula providers from the Grid's configured formulaProviders.

grid: Gridreadonly

Get the Grid instance to which this column belongs

pinned: start | end | null | falseAlso a config

Set to 'end' or 'start' to pin the column to the respective side of the grid when PinColumns feature is enabled.

When a column is pinned and it does not have a width specified, pinnedWidth will be used instead.

Set this to true to not allow any type of editing in this column.

subGrid: SubGridreadonly

Get the SubGrid to which this column belongs

textElement: HTMLElementreadonly

The text containing element for this Column. Only available after the grid has been rendered.

Note that column headers are rerendered upon mutation of Column values, so this value is volatile and should not be cached, but should be read whenever needed.

textWrapper: HTMLElementreadonly

The text wrapping element for this Column. Only available after the grid has been rendered.

This is the full-width element which contains the text-bearing element and any icons.

Note that column headers are rerendered upon mutation of Column values, so this value is volatile and should not be cached, but should be read whenever needed.

type: Stringreadonlystatic

Column name alias which you can use in the columns array of a Grid.

class MyColumn extends Column {
    static get type() {
       return 'mycolumn';
    }
}
const grid = new Grid({
   columns : [
      { type : 'mycolumn', text : 'The column', field : 'someField', flex : 1 }
   ]
});
type: Stringreadonly

Column name alias, which you can use in the columns array of a Grid. See type

visible: Boolean

Set this column to be visible or not

width: Number | StringAlso a config

Get/set columns width in px. If column uses flex, width will be undefined. Setting a width on a flex column cancels out flex.

NOTE: Grid might be configured to always stretch the last column, in which case the columns actual width might deviate from the configured width.

let grid = new Grid({
    appendTo : 'container',
    height   : 200,
    width    : 400,
    columns  : [{
        text  : 'First column',
        width : 100
    }, {
        text  : 'Last column',
        width : 100 // last column in the grid is always stretched to fill the free space
    }]
});

grid.columns.last.element.offsetWidth; // 300 -> this points to the real element width
$namestaticModel
relationsstaticModel

Rendering

A callback function called after every cell has been rendered, which lets you mutate the cell/row or contents. This is useful when you want to mutate contents of a pre-configured column (e.g. CheckColumn, WidgetColumn etc.) without overwriting the built-in renderer.

In the method, you can modify the cell / row elements, e.g. to add custom CSS classes:

new Grid({
    columns : [
        {
            text     : 'Name',
            afterRenderCell : ({ record, row, cellElement }) => {
                cellElement.classList.toggle('myClass', true);
                // Add special CSS class to new rows that have not yet been saved
                row.cls.newRow = record.isPhantom;
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject

Object containing rendering parameters

renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc. Can be null in case of export

renderData.value*

Value to be displayed in the cell

renderData.recordModel

Record for the row

renderData.columnColumn

This column

renderData.gridGrid

This grid

renderData.rowRow

Row object. Can be null in case of export. Use the row's API to manipulate CSS class names.

renderData.sizeObject

Set size.height to specify the desired row height for the current row. Largest specified height is used, falling back to configured rowHeight in case none is specified. Can be null in case of export

renderData.size.heightNumber

Set this to request a certain row height

renderData.size.configuredHeightNumber

Row height that will be used if none is requested

renderData.isExportBoolean

true if the record is being exported to Excel or a textual format, enabling special handling during export.

renderData.isMeasuringBoolean

True if the column is being measured for a resizeToFitContent call.

Returns: void | String | null -

Return value is only used by the export feature, not by row rendering

CSS class added to each cell in this column

CSS class added to the header of this column

Renderer function for group headers (when using Group feature).

You should never modify any records inside this method.
const grid = new Grid({
    columns : [
        {
            text : 'ABC',
            groupRenderer(renderData) {
                return {
                     class : {
                         big   : true,
                         small : false
                     },
                     children : [
                         { tag : 'img', src : 'img.png' },
                         renderData.groupRowFor
                     ]
                };
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject
renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc.

renderData.groupRowFor*

Current group value

renderData.recordModel

Record for the row

renderData.groupRecordsModel[]

Records in the group

renderData.columnColumn

Current rendering column

renderData.groupColumnColumn

Column that the grid is grouped by

renderData.countNumber

Number of records in the group

renderData.gridGrid

This grid

Returns: DomConfig | String | null -

The header grouping text or DomConfig object representing the HTML markup

Renderer function for the column header.

ParameterTypeDescription
renderDataObject
renderData.columnColumn

This column

renderData.headerElementHTMLElement

The header element

Returns: String | null -

The text or markup to show in the column header

Icon to display in header. Specifying an icon will render a <i> element with the icon as value for the class attribute

Renderer function, used to format and style the content displayed in the cell. Return the cell text you want to display. Can also affect other aspects of the cell, such as styling.

You should never modify any records inside this method.

If you provide a renderer to a built-in Column such as DateColumn, it will completely replace the native rendering. In these cases, you may want to call that column class's built-in renderer from your custom renderer to access the default rendered value.

If you mutate cellElement, and you want to prevent cell content from being reset during rendering, please return undefined from the renderer (or just omit the return statement) and make sure that the alwaysClearCell config is set to false.

new Grid({
    columns : [
        { text : 'Status', renderer : ({ record }) => record.status }
    ]
});

You can also return a DomConfig object describing the markup:

new Grid({
    columns : [
        {
             text : 'Status',
             renderer : ({ record }) => {
                 return {
                     class : 'myClass',
                     children : [
                         {
                             tag : 'i',
                             class : 'fa fa-pen'
                         },
                         {
                             tag : 'span',
                             text : record.name
                         }
                     ]
                 };
             }
        }
    ]
});

You can modify the row element too from inside a renderer to add custom CSS classes:

new Grid({
    columns : [
        {
            text     : 'Name',
            renderer : ({ record, row }) => {
               // Add special CSS class to new rows that have not yet been saved
              row.cls.newRow = record.isPhantom;

              return record.name;
        }
    ]
});

If you are adding a renderer to a column that has a built in renderer (like DateColumn or NumberColumn), you may call the built-in renderer from your custom renderer if you want to use the default content and modify it. For example, to highlight modified dates in a DateColumn:

new Grid({
    columns : [
        {
            type     : 'date',
            field    : 'startDate',
            text     : 'Start Date',
            renderer : ({ record, column }) => {
                let result = this.defaultRenderer(...arguments);

                // Highlight modified start dates
                if (record.isFieldModified('startDate')) {
                    result = `<span class="modified">${result}</span>`;
                }
                return result;
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject

Object containing renderer parameters

renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc. Can be null in case of export

renderData.value*

Value to be displayed in the cell

renderData.recordModel

Record for the row

renderData.columnColumn

This column

renderData.gridGrid

This grid

renderData.rowRow

Row object. Can be null in case of export. Use the row's API to manipulate CSS class names.

renderData.sizeObject

Set size.height to specify the desired row height for the current row. Largest specified height is used, falling back to configured rowHeight in case none is specified. Can be null in case of export

renderData.size.heightNumber

Set this to request a certain row height

renderData.size.configuredHeightNumber

Row height that will be used if none is requested

renderData.isExportBoolean

true if the record is being exported to Excel or a textual format, enabling special handling during export.

renderData.isMeasuringBoolean

True if the column is being measured for a resizeToFitContent call. In which case an advanced renderer might need to take different actions.

Returns: String | DomConfig | DomConfig[] | HTMLElement | null

A tooltip string to show when hovering the column header, or a config object which can reconfigure the shared tooltip by setting boolean, numeric and string config values.

tooltipRenderer: function | BooleanAlso a config

Renderer function for the cell tooltip (used with CellTooltip feature). Specify false to disable tooltip for this column.

You should never modify any records inside this method.
ParameterTypeDescription
renderDataObject
renderData.cellElementHTMLElement

Cell element

renderData.recordModel

Record for cell row

renderData.columnColumn

Cell column

renderData.cellTooltipCellTooltip

Feature instance, used to set tooltip content async

renderData.eventMouseEvent

The event that triggered the tooltip

Returns: String | DomConfig | null

Summary

sum: sum | add | count | countNotEmpty | average | functionAlso a config

Summary type (when using Summary feature). Valid types are:

  • 'sum' - Sum of all values in the column
  • 'add' - Alias for sum
  • 'count' - Number of rows
  • 'countNotEmpty' - Number of rows containing a value
  • 'average' - Average of all values in the column
  • callbackFn - A custom function, used with store.reduce. Its return value becomes the value of the accumulator parameter on the next invocation of callbackFn
ParameterTypeDescription
resultNumber | *

The value resulting from the previous call to callbackFn. On the first call, its value is initialValue if the latter is specified; otherwise its value is first element.

valueModel

The value of the current element.

indexNumber

The index position of currentValue. On the first call, its value is 0 if initialValue is specified, otherwise 1.

Returns: Number | *

Summary configs, use if you need multiple summaries per column. Replaces sum and summaryRenderer configs.

Renderer function for summary (when using Summary feature). The renderer is called with an object having the calculated summary sum parameter. Function returns a string value to be rendered.

Example:

columns : [{
    type            : 'number',
    text            : 'Score',
    field           : 'score',
    sum             : 'sum',
    summaryRenderer : ({ sum }) => `Total amount: ${sum}`
}]
ParameterTypeDescription
dataObject

Object containing renderer parameters

data.sumNumber | *

The sum parameter

Returns: String | DomConfig | null

Editing

copyOfModel
isValidModel

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

JSON

jsonModel

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Functions

77

Other

This property only exists if this column has its own specialized renderer, such as DateColumn, NumberColumn etc.

Call this function from inside your custom renderer to get the default rendered value of the column. For example:

new Grid({
    columns : [
        {
            type     : 'date',
            field    : 'startDate',
            text     : 'Start Date',
            renderer : ({ record, column }) => {
                let result = this.defaultRenderer(...arguments);

                // Highlight modified start dates
                if (record.isFieldModified('startDate')) {
                    result = `<span class="modified">${result}</span>`;
                }
                return result;
            }
        }
    ]
});
ParameterTypeDescription
renderDataObject

Object containing renderer parameters

renderData.cellElementHTMLElement

Cell element, for adding CSS classes, styling etc. Can be null in case of export

renderData.value*

Value to be displayed in the cell

renderData.recordModel

The record from which the cell's value is derived.

renderData.columnColumn

This column

renderData.gridGrid

This grid

renderData.rowRow

Row object. Can be null in case of export. Use the row's API to manipulate CSS class names.

renderData.isExportBoolean

true if the record is being exported to Excel or a textual format, enabling special handling during export.

renderData.isMeasuringBoolean

True if the column is being measured for a resizeToFitContent call. In which case an advanced renderer might need to take different actions.

Returns: DomConfig | String | null

Extracts the value from the record specified by this Column's field specification in a format that can be used as a value to match by a filtering operation.

The default implementation returns the getRawValue value, but this may be overridden in subclasses.

ParameterTypeDescription
recordModel

The record from which to extract the field value.

Returns: * -

The value of the referenced field if any.

Extracts the value from the record specified by this Column's field specification.

This will work if the field is a dot-separated path to access fields in associated records, eg

 field : 'resource.calendar.name'

Note: This is the raw field value, not the value returned by the renderer.

ParameterTypeDescription
recordModel

The record from which to extract the field value.

Returns: * -

The value of the referenced field if any.

Hides this column.

Refresh the cell for supplied record in this column, if that cell is rendered.

ParameterTypeDescription
recordModel

Record used to get row to update the cell in

Refreshes all the cells for this column

Rerender the header for this column

Resizes the column to match the widest string in it. By default it also measures the column header, this behaviour can be configured by setting resizeToFitIncludesHeader.

Called internally when you double-click the edge between column headers, but can also be called programmatically. For performance reasons it is limited to checking 1000 rows surrounding the current viewport.

ParameterTypeDescription
widthMinNumber | Number[]

Minimum allowed width. If content width is less than this, this width is used instead. If this parameter is an array, the first element is widthMin and the seconds is widthMax.

widthMaxNumber

Maximum allowed width. If the content width is greater than this number, this width is used instead.

Shows this column.

Toggles the column visibility.

ParameterTypeDescription
forceBoolean

Set to true (visible) or false (hidden) to force a certain state

Toggles the column visibility of all children of a parent column.

ParameterTypeDescription
columnsColumn[]

The set of child columns to toggle, defaults to all children

forceBoolean

Set to true (visible) or false (hidden) to force a certain state

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Parent & children

Insert a child column(s) before an existing child column. Returns null if the parent column is sealed

ParameterTypeDescription
childColumnModel | Model[]

Column or array of columns to insert

beforeModel

Optional column to insert before, leave out to append to the end

silentBoolean

Pass true to not trigger events during insert

Returns: Model | Model[] | null
appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Configuration

applyDefaultsstaticBase

Editing

copyModel
getDataModel
removeModel
setModel

Events

Fields

addFieldstaticModel
getModel
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Misc

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase
optionalLstaticLocalizable

Events

5

This event is triggered by the Grid when a parent column is about to be collapsed or expanded.

// Adding a listener using the "on" method
column.on('beforeColumnCollapseToggle', ({ source, column }) => {

});
ParameterTypeDescription
sourceGrid

The grid instance.

columnColumn

The column.

This event is triggered by the Grid when a parent column is collapsed or expanded.

// Adding a listener using the "on" method
column.on('columnCollapseToggle', ({ source, column }) => {

});
ParameterTypeDescription
sourceGrid

The grid instance.

columnColumn

The column.

catchAllEvents
destroyEvents

Event handlers

5

This event is called by the Grid when a parent column is about to be collapsed or expanded.

new Column({
    onBeforeColumnCollapseToggle({ source, column }) {

    }
});
ParameterTypeDescription
sourceGrid

The grid instance.

columnColumn

The column.

This event is called by the Grid when a parent column is collapsed or expanded.

new Column({
    onColumnCollapseToggle({ source, column }) {

    }
});
ParameterTypeDescription
sourceGrid

The grid instance.

columnColumn

The column.

onDestroyEvents

Typedefs

2