How to get rid of Uncaught TypeError: e.template is not a function ?

Hi,

I have two sets of datatable which are getting loaded by the press of Load-1 and Load-2 buttons. But after setting one set of data, the next set is not getting loaded and I am getting error as Uncaught TypeError: e.template is not a function in the console.

For me the datatable is same for both the cases, the only thing dynamically changing is the column names and the data.

Snippet:https://snippet.webix.com/cw3lvrc9

I need a button in the last cell (or column) so I used the template, but it seems to be a problem, kindly suggest a solution.

Thanks

Please check the updated snippet
https://snippet.webix.com/b22yyx9r

When you are changing the structure of datatable, you need to call refreshColumns API.

function loadValues() { 
   $$('mytable').clearAll();
   $$('mytable').refreshColumns(mycols);
   $$('mytable').parse(mydata);   
}

Thanks a lot, it worked.