Binding to Row, Cell and Column Events in Grid Web Component

This post shows how to bind to the Grid Web Component events. The code below initializes the Grid instance and binds to the 'click' event. Within the event handler, we can get details about which part of the Grid was clicked - Cell, Row or Column. This is achieved by utilizing the 'event.path' array. It is also important to note that each Data Grid Column has 'data-field' attribute and each Row has 'data-id' attribute. The data source, which is used in the example is available in the 'data.js' file from the download package.

 Smart('#grid', class {
      get properties() {
           return {
                dataSource: new Smart.DataAdapter(
                     dataSource: getCountriesData(),
                          'ID: number',
                          'Country: string',
                          'Area: number',
                          'Population_Urban: number',
                          'Population_Rural: number',
                          'Population_Total: number',
                          'GDP_Agriculture: number',
                          'GDP_Industry: number',
                          'GDP_Services: number',
                          'GDP_Total: number'
                columns: [
 window.onload = function() {
  grid.addEventListener('click', function(event){
     const path = event.path;
     let cell = null;
     let row = null;
     let column = null;
     for(let i = 0; i < path.length; i++) {
       const node = path[i];
       if (node.nodeName === 'SMART-GRID-CELL') {
         cell = node;
       if (node.nodeName === 'SMART-GRID-ROW') {
         row = node;
       if (node.nodeName === 'SMART-GRID-COLUMN')      {
         column = node;
     if (row) {
     if (column) {
     if (cell) {

This entry was posted in Smart Grid, Web Components and tagged , . Bookmark the permalink.

Leave a Reply