Hi, I hope you guys are doing great!
I am following this example for conditional formatting (https://handsontable.com/docs/8.2.0/demo-conditional-formatting.html), but I’m having trouble getting it to work in Vue.
If I add the renderer as a method of the component, the new styles are not applied. If, however, the renderer is outside of the component, then it works.
Something like this:
<script>
function myRenderer (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments)
td.style.color = 'blue'
td.style.background = 'red'
}
export default {
name: 'MyComponent',
mount() {
// Fetch some data with HTTP
},
data () {
return {
hotSettings: {
cells: function (row, col) {
const cellProperties = {}
if (row === 0) {
cellProperties.renderer = myRenderer // Works
// cellProperties.renderer = this.myRenderer // Doesn't Work
}
return cellProperties
},
// ...
}
}
},
methods: {
myRenderer (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments)
td.style.color = 'blue'
td.style.background = 'red'
},
}
}
</script>
Am I missing something? Is there a way to do it all in Vue world?
My use case is simple. I need to format each cell based on some metadata. This metadata is fetched separately from the data itself.