API Events

ZingGrid comes with its own set of events that work similarly to modern event handlers. Many of these events help signal when the grid or its components are rendered, or when an interaction occurs.

Grid Events

zing-grid refers to the grid, and its events target the grid as a whole (zing-grid Events Playground).

Example Usage

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('grid:ready', function(e) {
  console.log('--- (grid:ready) event fired ---', e);
});

Card Events

zg-card events are events that target the grid as a whole (zg-card Events Playground).

Example Usage

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('card:click', function(e) {
  console.log('--- (card:click) event fired ---', e);
});

Cell Events

zg-cell events are events that are triggered by each individual cell of the grid (zg-cell Events Playground).

Example Usage

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('cell:click', function(e) {
  console.log('--- (cell:click) event fired ---', e);
});

When implementing your own custom renderer function and binding an event, only attempt to bind events to contents of zg-cell! Do not bind events to zg-cell or zg-row — these components are reused to enhance performance. To bind events to zg-cell or zg-row, please use ZingGrid's custom events.

Edit
Download
CloseCopy Copied
CloseCopy Copied
CloseCopy Copied

Column Events

zg-column refers to the columns of the grid. Events triggered by columns are zg-column events (zg-column Events Playground).

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('column:click', function(e) {
  console.log('--- (column:click) event fired ---', e);
});

Data Events

zg-data events relate to data and any changes made to a record (zg-data Events Playground).

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('data:load', function(e) {
  console.log('--- (data:load) event fired ---', e);
});

Header Events

zg-header events are triggered by the header cell of a column (zg-header Events Playground).

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('header:click', function(e) {
  console.log('--- (header:click) event fired ---', e);
});

Record Events

A record refers to a row and card in the grid. Events triggered by row and card mode are grouped into record events.

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('record:click', function(e) {
  console.log('--- (record:click) event fired ---', e);
});

Row Events

zg-row refers to a row in the grid. Events triggered by rows are zg-row events (zg-row Events Playground).

CloseCopy Copied
const zgRef = document.querySelector('zing-grid');
zgRef.addEventListener('row:click', function(e) {
  console.log('--- (row:click) event fired ---', e);
});

When implementing your own custom renderer function and binding an event, only attempt to bind events to contents of zg-cell! Do not bind events to zg-cell or zg-row — these components are reused to enhance performance. To bind events to zg-cell or zg-row, please use ZingGrid's custom events.

Edit
Download
CloseCopy Copied
CloseCopy Copied
CloseCopy Copied
loadingloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadBgloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloadingloading