Access class variable inside renderers

Tags: #<Tag:0x00007f8b2b0df5f8>

I am using renderers on my column data that gets displayed. Is there a way to access the class variable inside the renderers?

public class ABC {
accessThisVariable = true;
this.columns[
{ data: ‘id’, type: ‘text’, renderer: this.dataRenderer},
{ data: ‘name’, type: ‘text’, renderer: this.dataRenderer}
]
dataRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
// access here the class variable ‘accessThisVariable’
}
}

Hi @krish,

Thank you for your question. I’m writing to let you know that we’re currently working on it and will get back to you soon.
Thank you for your patience.

Natalia

That’s wonderful.

Hey @krish

have you tried this approach https://jsfiddle.net/ujz3kodh/? Does it meet your requirements?

Hi,
I haven’t tried. Let me try.

Thanks!

I am not able to access that in the renderer as shown in fiddler. Gives error
I have a constructor:

constructor(…){
const that = this;
this.somecolumn = [
{renderer: this.callRenderer}
];
}

checkBoxRenderer(instance, td, row, col, prop, value, cellProperties) {
console.log(that);

If it works in the Fiddle but you get the error some other code might be coming or you use a different class structure. I would need to check your code to give more hints.