Highcharts

Start your Highcharts journey today

立即试用
立即购买
Skip to Content

tags: [“grid-pro”]

Events

The Grid supports event listeners that can be added to the columnDefaults.events  object or a particular column. These listeners will call functions when interacting with the Grid.

Please note that the events  has been deprecated.

The available events are:

cell

Event NameDescriptionFunction Context
afterEditTriggered after a cell’s value is edited.this: Cell
afterRenderTriggered after setting a cell’s value (init/edit)this: Cell
afterSetValueDeprecated. Use afterRender instead.this: Cell
clickTriggered after clicking on a cell.this: Cell
dblClickTriggered after double-clicking on a cell.this: Cell
mouseOverTriggered when the mouse is hovered over a cell.this: Cell
mouseOutTriggered when the mouse leaves a cell.this: Cell

column

Event NameDescriptionFunction Context
afterResizeTriggered after resizing a column.this: Column
afterSortingTriggered after sorting a column.this: Column
Event NameDescriptionFunction Context
clickTriggered after clicking on a column header.this: Column
afterRenderTriggered after init of a column header.this: Column

Example

Here is a sample code that demonstrates how to use these event callbacks in the events object:

columnDefaults: { events: { afterResize: function () { console.log('Column resized:', this); }, afterSorting: function () { console.log('Column sorted:', this); } }, cells: { events: { afterEdit: function () { console.log('Cell value set:', this); }, afterRender: function () { console.log('Cell value:', this); }, click: function () { console.log('Cell clicked:', this); }, dblClick: function () { console.log('Cell double-clicked:', this); }, mouseOver: function () { console.log('Mouse over cell:', this); }, mouseOut: function () { console.log('Mouse out of cell:', this); } } }, header: { events: { click: function () { console.log('Header clicked:', this); } } } }

You can also declare all events to the dedicated column:

columns: [{ id: 'columnId', events: { afterResize: function () { // callback } } cells: { events: { click: function () { // callback } } }, header: { events: { click: function () { // callback } } } }]

Live example: