Editable table column data In drupal 8, I am writing a custom module and in one of the function in controller -I am fetching data from an external API, then displaying it in table format using -
 foreach($rec as $data) {
    ksm($data);
    $rows[] = [// mydata
]};

return [
    '#type' =&gt; 'table',
    '#header' =&gt; $header,
    '#rows' =&gt; $rows,

  ];

This is working correctly.
But I want table cells to be editable and when user edits the data, a listener gets invoked (or provide an update button for the user).
Now this listener would  do some stuff  with updated data(make external API call).
My doubt is how can we do this with tables? Is there any way to make some columns of table editable and register a listener in Drupal.
Would I need to create a node for each row of this table data?
If a node is required, then how to do ?
I am new to Drupal 8, just started a month ago, kindly help.
Thanks in advance.
What you can do is first create nodes using the API data and create a table view. so that the views fields can be referenced to nodes and they can be updated.
By this way you wont be needing any additional event handlers.
To Create Nodes you can use the following snippet:
use \Drupal\node\Entity\Node;

$node = Node::create([

       'type' =&gt; 'new_content_type',

       'title' =&gt; 'Creating a new node',

       'body' =&gt; 'Body of the node',

       'field_mail'=&gt;'email@gmail.com',

       'field_link'=&gt;'http://www.example.com',

       'field_date'=&gt;[ '2017-07-22', ],

]);  
$node-&gt;enforceIsNew();
$node-&gt;save();