Skip to main content English Español Claro Oscuro Sistema

Data Grid

<gstock-data-grid> | GstockDataGrid

API

Propiedades

Nombre Descripción Reflects Tipo Por defecto
columns The columns configuration for the data grid. Each column defines how data should be displayed and behave. DataGridColumn[] []
data The data rows to be displayed in the grid. Each row should have an ‘id’ property and keys matching column keys. DataGridRow[] []
size The size variant of the data grid. Affects padding, font sizes, and overall spacing. Reflects 'small' | 'medium' | 'large' 'medium'
striped When true, alternating rows will have a different background color for better readability. Reflects boolean false
bordered When true, adds borders around the entire grid and between cells. Reflects boolean false
hoverable When true, rows will highlight when hovered over with the mouse. Reflects boolean false
compact When true, reduces padding and spacing for a more compact layout. Reflects boolean false
selectable When true, enables row selection functionality with checkboxes. Reflects boolean false
multiSelect
multi-select
When true and selectable is enabled, allows multiple rows to be selected simultaneously. Reflects boolean false
isRowSelectable Optional predicate to decide whether a given row can be selected. When set, non-selectable rows are skipped by selectAll, ignored by the header checkbox state, and their per-row checkbox is disabled. (row: DataGridRow) => boolean | undefined -
sortable When true, enables column sorting functionality. Individual columns can override this with their sortable property. Reflects boolean false
filterable When true, enables column filtering functionality. Individual columns can override this with their filterable property. Reflects boolean false
resizable When true, enables column resizing functionality. Individual columns can override this with their resizable property. Reflects boolean false
paginated When true, enables pagination controls and limits the number of rows displayed per page. Reflects boolean false
pageSize
page-size
The number of rows to display per page when pagination is enabled. Reflects number 25
currentPage
current-page
The current page number (1-based) when pagination is enabled. Reflects number 1
totalPages
total-pages
The total number of pages available. - If set to 0 or not provided: Calculated automatically from data.length and pageSize (virtual pagination) - If set to a value > 0: Used for server-side pagination where data contains only current page items Reflects number 0
totalItems
total-items
The total number of items across all pages. - If set to 0 or not provided: Calculated automatically from data.length (virtual pagination) - If set to a value > 0: Used for server-side pagination where data contains only current page items Reflects number 0
showPageSizeSelector
show-page-size-selector
When true, displays a selector for changing the page size in the pagination controls. Reflects boolean false
expandable When true, enables row expansion functionality. Reflects boolean false
expandedContentRenderer Function to render the expanded content for a row. Receives the row data, row index, and grid columns to allow flexible rendering. ExpandedContentRenderer | undefined -
expandOnRowClick
expand-on-row-click
When true, allows expanding/collapsing rows by clicking anywhere on the row. When false, expansion is only triggered by clicking the specific expand button element. Reflects boolean false
noHeader
no-header
When true, hides the header row containing column titles. Reflects boolean false
loading When true, displays a loading state with a progress indicator and hides the data grid content. Reflects boolean false
loadingMessage
loading-message
The message to display while the grid is in a loading state. - -
emptyMessage
empty-message
The message to display when the grid has no data to show. - -
updateComplete

A read-only promise that resolves when the component has finished updating.

Aprende más sobre atributos y propiedades .

Eventos

Nombre React Event Descripción Event Detail
gstock-data-grid-sort-change-event onGstockDataGridSortChangeEvent Fired when the sort state changes. -
gstock-data-grid-filter-change-event onGstockDataGridFilterChangeEvent Fired when the filter state changes. -
gstock-data-grid-selection-change-event onGstockDataGridSelectionChangeEvent Fired when the selection state changes. -
gstock-data-grid-row-click-event onGstockDataGridRowClickEvent Fired when a row is clicked. -
gstock-data-grid-row-expand-event onGstockDataGridRowExpandEvent Fired when a row is expanded. -
gstock-data-grid-row-collapse-event onGstockDataGridRowCollapseEvent Fired when a row is collapsed. -
gstock-data-grid-cell-click-event onGstockDataGridCellClickEvent Fired when a cell is clicked. -
gstock-data-grid-column-resize-event onGstockDataGridColumnResizeEvent Fired when a column is resized. -
gstock-page-change-event onGstockPageChangeEvent Fired when the page changes. -
gstock-page-size-change-event onGstockPageSizeChangeEvent Fired when the page size changes. -

Aprende más sobre eventos .

Slots

Nombre Descripción
(default) The default slot for data grid content.
toolbar Toolbar content displayed above the grid.
empty Content displayed when the grid is empty.
loading Content displayed when the grid is loading.

Aprende más sobre slots .

Métodos

Nombre Descripción
deselectAll( ) Deselects only the rows visible in the current page. Selections from other pages persist. Use clearSelection() to wipe the full selection.
clearSelection( ) Clears the entire selection across all pages.
selectAllPages(
ids: (string | number)[] ,
dataById: Map<string | number, DataGridRow>
)
Adds the given IDs to the selection. Intended for the “select all filtered rows” flow under server-side pagination: the consumer resolves the IDs from its backend (using the active filter) and hands them to the grid. Optional dataById lets the consumer also seed the cached row payload for rows that are not present in the current page, so selectedData reflects them.
getHeaderCell(
index: number
)
Gets a header cell element by index.
getSelectionCheckbox(
rowIndex: number
)
Gets a selection checkbox element.
getRow(
index: number
)
Gets a row element by index.
getCell(
rowIndex: number ,
columnIndex: number
)
Gets a cell element by row and column index.

Aprende más sobre métodos .

Propiedades personalizadas

Nombre Descripción Default
--background-color Controls the grid background color.
--border-color Controls the grid border color.
--border-width Controls the grid border width.
--cell-padding Controls the padding of grid cells.
--header-background Controls the header background color.
--row-height Controls the default row height.
--stripe-color Controls the alternating row color.

Aprende más sobre propiedades personalizadas .

Partes

Nombre Descripción
container The component’s container.
toolbar The toolbar container.
grid-container The scrollable container that wraps the grid.
grid The main grid container.
header The header row container.
header-cell Individual header cells.
body The body container.
row Individual row containers.
cell Individual cell containers.
cell-content The inner wrapper that holds the rendered cell value.
expanded-row Expanded row containers.
expanded-cell The cell containing expanded content.
pagination The pagination container.
pagination-container The pagination wrapper container.
pagination-loading The pagination loading indicator.
selection-checkbox Selection checkboxes.
sort-button Sort buttons in headers.
empty-state The empty state container.
loading The loading state container.
resize-handle Column resize handles.

Aprende más sobre partes CSS .