Search code examples
tabulator

cellEdited not triggering in version 5.0.7


I can't get cellEdited to trigger in version 5.0 or greater - it did in 4.9 and does not work in v5.+

I read through the upgrade docs, but didn't see anything that might have changed for this feature.

Here is a small example of what worked before but no longer works.

Thanks in advance.

<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
  <script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
</head>

<body>
  <div id="example-table"></div>
</body>
<script>
  var tabledata = [{
    id: 1,
    name: "Oli Bob"
  }, ];

  //Build Tabulator
  var table = new Tabulator("#example-table", {
    height: "311px",
    columns: [{
      title: "Name",
      field: "name",
      width: 150,
      editor: "input",
      cellEdited: (cell) => (console.log('edited'))
    }, ],
    data: tabledata
  });
</script>

</html>

Solution

  • Starting with V5.0, most callbacks have now been replaced with events. Try using:

    table.on('cellEdited', () => {
      //do something
    })
    

    Here is an example:

    <!doctype html>
    <html lang="en">
    
    <head>
      <meta charset="utf-8">
      <link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
      <script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
    </head>
    
    <body>
      <div id="example-table"></div>
    </body>
    <script>
      var tabledata = [{
        id: 1,
        name: "Oli Bob"
      }, ];
    
      //Build Tabulator
      var table = new Tabulator("#example-table", {
        height: "311px",
        columns: [{
          title: "Name",
          field: "name",
          width: 150,
          editor: "input"
        }],
        data: tabledata
      });
    
      table.on('cellEdited', (cell) => {
        console.log('edited')
      })
    </script>
    
    </html>