New to Kendo UI for AngularStart a free 30-day trial

GridComponent

Component

Represents the Kendo UI for Angular Data Grid component.

Use the kendo-grid component to display and manage tabular data.

Definition

Package:@progress/kendo-angular-grid

Selector:kendo-grid

Export Name:Accessible in templates as #kendoGridInstance="kendoGrid"

Syntax:

html
<kendo-grid [data]="gridData"></kendo-grid>

Inputs

Enables or disables adaptive mode. Adaptive rendering is off by default.

Default:

'none'

autoSize

boolean

If true, resizes columns during initialization to fit headers and content. Columns with autoSize set to false are excluded. See example.

Default:

false

Sets a function to determine if a data cell is selected. The function returns an object with selected and item properties (see example).

If true, displays the column menu for columns (see example).

Default:

false

Sets the data of the Grid. If you provide an array, the Grid gets the total count automatically. (more information and example).

Sets the Grid data layout display mode.

Default:

'columns'

Sets the style.height attribute of each Grid detail row (tr.k-detail-row) element in the DOM in pixels. If the detail row has content that requires more space, the row automatically expands to fit the content.

Sets the filter descriptor for the data (see examples).

Enables the filtering feature of the Grid for columns with a field option.

Default:

false

Determines if the Grid can be resized.

Default:

false

group

GroupDescriptor[]

Sets the descriptors for grouping the data (see example).

If true, allows grouping by dragging column headers (see example).

Default:

false

height

number

Defines the height in pixels for the Grid when scrollable is set. You can also set the height using style.height with units like px, %, em, or rem.

hideHeader

boolean

If true, hides the Grid header. The header is visible by default. The header includes column headers and the filter row.

Default:

false

isDetailExpanded

(args: RowArgs) => boolean

Sets a function to determine if a specific row is expanded.

isGroupExpanded

(args: GroupRowArgs) => boolean

Sets a function to determine if a specific group row is expanded.

Sets a function to determine if a data row is pinnable.

Sets a function to determine if a data row is selectable.

loading

boolean

If true, displays the Grid loading indicator (see example).

Default:

false

By default, navigation is enabled. To disable, set to false. To enable navigation for specific sections, provide a GridNavigableSection.

Configures the Grid pager (see example).

Default:

false

pageSize

number

Defines the page size used by the Grid pager. Required for the paging feature.

Enables the end user to pin rows through the UI. You can set it to true to allow pinning to both top and bottom, or specify the desired pinning location by providing a GridRowPinLocation. By default, the row pinning feature is disabled.

Default:

false

The array of data items pinned to the bottom of the Grid. Pinned rows remain visible while the body scrolls and are immune to filtering and pagination.

Requires setting pinnable to true or a valid GridRowPinLocation.

The array of data items pinned to the top of the Grid. Pinned rows remain visible while the body scrolls and are immune to filtering and pagination.

Requires setting pinnable to true or a valid GridRowPinLocation.

If true, allows reordering columns by dragging header cells (see example).

Default:

false

If true, allows resizing columns by dragging header cell edges (see example).

Default:

false

Sets a function to apply custom CSS classes to each data row (see example).

rowHeight

number

Sets the style.height attribute of each Grid data or group header/footer row (tr) element in the DOM in pixels. If some row cells have content that requires more space, the row automatically expands to fit the content.

Enables row reordering feature of the Grid (see example).

Default:

false

Sets a function to determine if a data row is selected (see example).

Sets a function to determine if a data row is sticky (always visible after scrolling).

Defines the scroll mode for the Grid.

Default:

'scrollable'

Enables the selection feature of the Grid. The selectable property can be set to true, false, or an object with additional settings. See example.

Default:

false

Specifies if the currently inactive toolbar tools will be visible. Applicable when the toolbar is configured using the <kendo-toolbar> component. By default, such tools are hidden.

Default:

false

Specifies the sizing for Grid elements like tables, buttons, and inputs.

Default:

undefined

skip

number

Defines the number of records to skip in the pager. Required for the paging feature.

sort

SortDescriptor[]

Sets the descriptors for sorting the data (see example).

Enables sorting feature of the Grid for columns with a field option.

Default:

false

A function that defines how to track changes for the data rows. By default, the Grid tracks changes by the index of the data item. Edited rows are tracked by reference. See example.

Default:

defaultTrackBy

If true, renders only columns in the current viewport.

Default:

false

Fields

Returns the currently focused cell (if any).

Returns the currently focused row (if any).

A query list of all declared columns.

Gets the current GridState, including data operations and column state. Use this to store and restore the Grid state.

Events

Fires when a new row is added by clicking the Add command button (see example).

Fires when editing is canceled by clicking the Cancel command button (see example).

Fires when a cell is clicked (see example).

Fires when a cell edit is closed (see example).

Fires when columns are locked or unlocked.

Fires when columns are reordered.

Fires when columns are resized.

Fires when columns are made sticky or unsticky.

Fires when column visibility changes.

Fires when the grid content is scrolled. The event is triggered outside the Angular zone for performance. Enter the Angular zone if you make changes that require change detection.

Fires when the CSV export command is triggered.

Fires when the data state of the Grid is changed.

Fires when a detail row is collapsed through the UI.

Fires when a detail row is expanded through the UI.

Fires when a row enters edit mode (see example).

Fires when the Excel export command is triggered.

Fires when the Grid data is filtered through the UI and the filter descriptor changes.

Fires when the data or columns state of the Grid is changed.

groupChange

EventEmitter​<GroupDescriptor[]>

Fires when the Grid data is grouped through the UI and the group descriptors change (see example).

Fires when a group is collapsed through the UI.

Fires when a group is expanded through the UI.

Fires when the page is changed through the UI (see example).

Fires when the PDF export command is triggered.

Fires when a row is removed by clicking the Remove command button (see example).

Fires when a row’s pinned state is updated through the UI.

Fires when a row is reordered through the UI.

Fires when a row is saved by clicking the Save command button (see example).

Fires when the last record is scrolled into view (see example).

Fires when the Grid selection changes through the UI.

sortChange

EventEmitter​<SortDescriptor[]>

Fires when the Grid data is sorted through the UI and the sort descriptors change (see example).

Methods

Creates a new row editor (see example).

Parameters:groupany

The FormGroup that describes the edit form. If you pass a data item, the method builds the FormGroup from the data item fields.

Applies the minimum possible width for the specified column so the whole text fits without wrapping. This method expects the Grid to be resizable. Run this method after the Grid is populated with data. See example

Parameters:columnColumnBase

Adjusts the width of the specified columns to fit the entire content, including headers, without wrapping. If you do not specify columns, autoFitColumns applies to all columns. Run this method after the Grid is populated with data. See example

Parameters:columnsColumnBase[] | QueryList​<ColumnBase>

Adjusts the width of the Grid columns to fit the entire Grid width.

  • when the sum of all columns widths is less than the available Grid width—the available space is distributed evenly between all columns.
  • when the sum of all columns widths is greater than the available Grid width—the columns are shrinked equally to fit the Grid width.

Run this method after the Grid is populated with data.

Closes the current cell in edit mode.

Clears the search operation applied through the SmartBox tool.

Closes the current cell in edit mode and fires the cellClose event.

Returns:

boolean

true if the cell closed. Returns false if the cellClose event was prevented.

Closes the editor for the specified row (see example).

Parameters:index?number

The row index to switch out of edit mode. If you do not provide an index, the new item editor closes.

Collapses a group header at the given hierarchical index, such as 0_1 for the second inner group of the first master group.

This method is for backwards compatibility with legacy versions that track expanded group state by hierarchical group index. If the Grid is pageable, the group indexes are offset by the current Grid skip.

Parameters:indexstring

The underscore-separated hierarchical index of the group.

Collapses the master row at the specified data row index (see example).

This method is for backwards compatibility with legacy versions that track expanded state by row index. For new development, use the kendoGridDetailsExpandBy directive or provide an isDetailExpanded callback. See Controlling the Expanded State for examples.

Parameters:indexnumber

The data row index of the master row.

Exports the Grid element to a Drawing Group using the kendo-grid-pdf component options (see example).

Returns:

Promise​<any>

A promise that resolves with the Drawing Group.

Puts the specified cell in edit mode (see example).

Parameters:rowIndexnumber

The data row index to switch to edit mode.

columnany

The leaf column index, field name, or column instance to edit.

group?any

The FormGroup that describes the edit form.

Switches the specified table row to edit mode (see example).

Parameters:rowIndexnumber

The data row index to switch to edit mode.

group?FormGroup​<any>

The FormGroup that describes the edit form.

options?EditRowOptions

Additional options to configure the focus target when the editor opens.

Expands a group header at the given hierarchical index, such as 0_1 for the second inner group of the first master group.

This method is for backwards compatibility with legacy versions that track expanded group state by hierarchical group index. If the Grid is pageable, the group indexes are offset by the current Grid skip.

Parameters:indexstring

The underscore-separated hierarchical index of the group.

Expands the master row at the specified data row index (see example).

This method is for backwards compatibility with legacy versions that track expanded state by row index. For new development, use the kendoGridDetailsExpandBy directive or provide an isDetailExpanded callback. See Controlling the Expanded State for examples.

Parameters:indexnumber

The data row index of the master row.

Focuses the last active or the first cell of the Grid.

Returns:

NavigationCell

The focused cell.

Focuses the cell with the specified row and column index.

The row index is based on the logical structure of the Grid and does not correspond to the data item index. Header rows are included, starting at index 0. Group headers and footers are included. The row indexing is absolute and does not change with paging.

If the Grid is configured for scrolling, including virtual scrolling, the scroll position will be updated. If the row is not present on the current page, the method will have no effect.

Parameters:rowIndexnumber

The logical row index to focus. The top header row has an index 0.

colIndexnumber

The column index to focus.

Returns:

NavigationCell

The focused cell.

Focuses the next cell, optionally wrapping to the next row.

Parameters:wrapboolean

A Boolean value which indicates if the focus will move to the next row. Defaults to true.

Returns:

NavigationCell

The focused cell. If the focus is already on the last cell, returns null.

Focuses the previous cell. Optionally wraps to the previous row.

Parameters:wrapboolean

A Boolean value which indicates if the focus will move to the next row. Defaults to true.

Returns:

NavigationCell

The focused cell. If the focus is already on the first cell, returns null.

Builds the request body for the AI service based on the provided prompt message. Allows developers to construct the AI service requests manually (see example).

Parameters:promptMessagestring

The prompt message to send to the AI service.

Returns:

any

The request body object ready to be sent to the AI service.

Processes an AI service response and applies the commands to the Grid. Allows developers to handle the AI service responses manually (see example).

Parameters:responseany

The AI service response containing optional message and commands array.

Returns true if a row or cell is currently edited.

Returns:

boolean

true if a row or cell is currently edited.

Returns true if a cell is currently edited.

Returns:

boolean

true if a cell is currently being edited.

Applies the given GridState object to the Grid.

Parameters:stateGridState

Changes the position of the specified column. The reordering of columns operates only on the level inferred by the source column. For this method to work, the source column must be visible.

Parameters:sourceColumnBase

The column to move.

destIndexnumber

The new position of the column.

optionsColumnReorderConfig

Additional options.

Initiates the CSV export (see example).

Initiates the Excel export (see example).

Initiates the PDF export (see example).

Scrolls to the specified row and column (see example).

Parameters:requestScrollRequest

Scrolls to the specified data item and column (see example).

Parameters:requestScrollToItemRequest

Generates and returns the CSV-formatted string without triggering file download (see example).

Returns:

string | Promise​<string>

The CSV-formatted string representation of the Grid data, or a Promise that resolves to the string if async data is used.