I should create an autocomplete or HOT-in-HOT, using hot-column. For example like this.
<hot-table>
<hot-column type="handsontable" data="code_id">
<hot-table [data]="codes" [autoColumnSize]="true">
<hot-column data="id" [renderer]="codesRenderer.bind(this)"></hot-column>
</hot-table>
</hot-column>
</hot-table>
Although it's not working in @handsontable/angular package, but works with setting object -> columns. Like this:
{
data: 'author_id',
title: 'Author',
editor: AuthorEditor,
type: 'handsontable',
handsontable: {
data: this.authorService.getAuthors(),
autoColumnSize: true,
columns: [
{
data: 'id',
renderer: (instance, TD, row) => {
const author: Author = instance.getSourceDataAtRow(row);
TD.innerText = `${author.first_name} ${author.last_name}`;
}
}
],
getValue() {
var selection = this.getSelected();
return this.getSourceDataAtRow(selection[0]).id;
}
},
renderer: (instance, TD, row, col, prop, value, cellProperties) => {
const author = this.authorService.getAuthorById(parseInt(value, 10));
if (!author) {
return;
}
TD.innerText = `${author.first_name} ${author.last_name}`;
},
}
I prefer using <hot-column></hot-column>
instead of setting object. How is it possible create handsontable type with <hot-column>
?